IPad UIModalPresentationFormSheet with UITabBarController moreNavigationController edit mode issue

This seems to be a mistake, but I wonder if anyone can think of a workaround.

On the iPad, you present the presentation controller as UIModalPresentationFormSheet. This view controller extends the UITabBarController and has enough controllers to automatically display the β€œmore” panel buttons. As soon as you click on the button more, it will display the list correctly, but as soon as you click on "edit", it will display the type of editing more than the actual sheet of the form (cropped inside the sheet of the form), as a result of which the content will be missing from viewing, including the panel tools with a done button. The only way to fire is to force you to exit the application.

To make sure that this is not something specific for my application, I started the project with one look and introduced a simple modal presentation. This modal view controller extends the UITabBarController and has the following init method:

- (id)init { self = [super init]; if (self) { self.modalPresentationStyle = UIModalPresentationFormSheet; NSMutableArray *controllers = [NSMutableArray array]; for (int i = 0; i< 15; i++) { UIViewController *vc = [[UIViewController alloc] init]; UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; vc.title = [NSString stringWithFormat:@"view %i", i]; [controllers addObject:nav]; } self.viewControllers = controllers; } return self; } 

I also tried adding modalPresentationStyle to moreNavigationController without change.

+6
source share
2 answers

Good afternoon, diz.

Good challenge you made. Here is a solution, maybe it's a bit hardcore, but it works.

I did as you wrote - subclassed the UITabBarController and introduced it as a modal controller. And to face the same problem. When you click the Edit button on the Advanced screen, a UITabBarCustomizeView appears and the frame is inadequate.

So, I did the following. I made MyModalTabBarVC my delegate and implemented the tabBarController:willBeginCustomizingViewControllers: method:

 - (void)tabBarController:(UITabBarController *)tabBarController willBeginCustomizingViewControllers:(NSArray *)viewControllers { UIView *modalView = self.view; CGRect bounds = modalView.bounds; UIView *customizationView = [[modalView subviews] objectAtIndex:1]; UIView *customizationNavBar = [[customizationView subviews] objectAtIndex:0]; CGRect navBarFrame = [customizationNavBar frame]; navBarFrame.size.width = bounds.size.width; customizationNavBar.frame = navBarFrame; customizationView.frame = bounds; } 

So, when this method is called UITabBarCustomizeView , it is already created. And the wrong frame can be manually changed. If you write po [self.view subviews] at the beginning, you get:

 (id) $1 = 0x06c6a940 <__NSArrayM 0x6c6a940>( <UITransitionView: 0xd744ab0; frame = (0 0; 540 571); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0xd744b50>>, <UITabBarCustomizeView: 0x6c5e570; frame = (0 -384; 768 1004); animations = { position=<CABasicAnimation: 0x6c569a0>; }; layer = <CALayer: 0x6c618d0>>, <UITabBar: 0xd744110; frame = (0 571; 540 49); autoresize = W+TM; layer = <CALayer: 0xd742b80>>, ) 

PS. This solution does not fix the animation. As you can see from the magazine, the damaged animation is already created and charged. I hope that canceling it and adding a new one will not be a problem.

+3
source

The modal view of the viewController should fail.

You may try:

  • hide the tab bar during editing and do not hide it when the "Finish" button.
  • create a custom toolbar for the view controller, this can be done with the UIView so that it is always installed on top of the view.
  • Resize individual tabs. The best way to do this is to create your own tab bar with connected UIViewController and IBActions in UIButtons with IBOutlets.

Why do you have so many tabs in modalPresentationStyle? I personally would use push segue instead.

Try moving on to a new set of view controllers, which are also under their own navigation controller. There will be more space for the tab bar. To return, place the "Back" button on the toolbar, which pushes the click or discards back to the original.

0
source

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


All Articles