Problem with UITabBar button, TabBar button becomes un clickable

I am creating a view with UINavigationBar and UITabBar . I added a button on the tab bar, when I click the button, I hide the tab bar and show the toolbar below. My code is written for both current and previous versions of iOS. I use this code self.edgesForExtendedLayout = UIRectEdgeNone; for iOS7, this is my code:

 - (void)hideTabBar { UITabBar *tabBar = self.tabBarController.tabBar; UIView *parent = tabBar.superview; // UILayoutContainerView UIView *content = [parent.subviews objectAtIndex:0]; // UITransitionView UIView *window = parent.superview;enter code here [UIView animateWithDuration:0.5 animations:^{ CGRect tabFrame = tabBar.frame; tabFrame.origin.y = CGRectGetMaxY(window.bounds); tabBar.frame = tabFrame; // CGRect contentFrame = content.frame; // contentFrame.size.height -= tabFrame.size.height; content.frame = window.bounds; }]; if ([[[UIDevice currentDevice] systemVersion] intValue] < 7.0) { CGRect frame = tbl_AllFiles.frame; frame.size.height -=tabBar.frame.size.height; tbl_AllFiles.frame = frame; } } - (void)showTabBar { UITabBar *tabBar = self.tabBarController.tabBar; UIView *parent = tabBar.superview; // UILayoutContainerView UIView *content = [parent.subviews objectAtIndex:0]; // UITransitionView UIView *window = parent.superview; if ([[[UIDevice currentDevice] systemVersion] intValue] < 7.0) { CGRect frame = tbl_AllFiles.frame; frame.size.height +=tabBar.frame.size.height; tbl_AllFiles.frame = frame; } [UIView animateWithDuration:0.5 animations:^{ CGRect tabFrame = tabBar.frame; tabFrame.origin.y = CGRectGetMaxY(window.bounds) - CGRectGetHeight(tabBar.frame); tabBar.frame = tabFrame; CGRect contentFrame = content.frame; contentFrame.size.height -= tabFrame.size.height; content.frame = contentFrame; }]; } - (void)loadToolBar { toolbar = [UIToolbar new]; toolbar.barStyle = UIBarStyleBlackTranslucent; moveButton = [UIButton buttonWithType:UIButtonTypeCustom]; [moveButton setFrame:CGRectMake(10, 10, 120, 25)]; [moveButton setBackgroundColor:[UIColor redColor]]; [moveButton setTitle:@"Move" forState:UIControlStateNormal]; [moveButton addTarget:self action:@selector(moveFile_Folder:) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *moveItem = [[[UIBarButtonItem alloc] initWithCustomView:moveButton] autorelease]; moveItem.style = UIBarButtonItemStyleBordered; NSArray *items = [NSArray arrayWithObjects:moveItem, nil]; toolbar.items = items; [toolbar sizeToFit]; CGFloat toolbarHeight = [toolbar frame].size.height; CGRect mainViewBounds = self.view.bounds; if ([[[UIDevice currentDevice] systemVersion] intValue] < 7.0) { [toolbar setFrame:CGRectMake(CGRectGetMinX(mainViewBounds), CGRectGetMinY(mainViewBounds) + CGRectGetHeight(mainViewBounds) - (toolbarHeight), CGRectGetWidth(mainViewBounds), toolbarHeight)]; } else { [toolbar setFrame:CGRectMake(CGRectGetMinX(mainViewBounds), CGRectGetMinY(mainViewBounds) + CGRectGetHeight(mainViewBounds), CGRectGetWidth(mainViewBounds), toolbarHeight)]; } [self.view addSubview:toolbar]; [toolbar bringSubviewToFront:self.view]; } 

My problem is with the hideTabBar button being pressed and the loadToolBar methods are being called. Everything works fine, except that the button on the toolbar is now unavailable. Please help me.

+6
source share
1 answer

I had a similar problem if your view manager is not a root view controller. iOS does not get a presentation frame.

Add this line to your viewcontroller in viewdidload,

 self.view.frame = [UIScreen mainScreen].bounds; 

hope this helps

0
source

Source: https://habr.com/ru/post/955464/


All Articles