开发者

Contained UISplitView not sending delegate methods

开发者 https://www.devze.com 2023-03-11 19:42 出处:网络
UISplitView has the following delegate methods that aid modification of layout during rotation: - (void)splitViewController:(UISplitViewController *)svc

UISplitView has the following delegate methods that aid modification of layout during rotation:

- (void)splitViewController:(UISplitViewController *)svc 
     willHideViewController:(UIViewController *)aViewController 
          withBarButtonItem:(UIBarButtonItem *)barButtonItem 
       forPopoverController: (UIPopoverController *)pc;

- (void)splitViewController:(UISplitViewController *)svc 
     willShowViewController:(UIViewController *)aViewController 
  invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem;

these methods are being respectively invoked by methods private to UISplitView, named _viewControllerHiding: and _updateMasterViewControllerFrame. Both of these are being invoked directly from the top of the event loop, apparently with a delayed invocation.

But, if I place my own view controller as window's root (you can't place a split view controller in a navigation controller), and place the split view subordinate to it, the delegate methods are not being sent appropriately. (Actually, one is sent on viewDidLoad, but none on rotations.) The hiding of the master view still occurs, but no delegate love to aid in layout (managing the popov开发者_运维知识库er/bar items).

I have tried forwarding the following view controller methods to the contained split view, but they aren't triggering it.

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation;
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 
                                duration:(NSTimeInterval)duration;
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
                                         duration:(NSTimeInterval)duration;

Anyone have any insight on how to get these UISplitView delegate methods to fire? Preferably not private API.


Take a look at Combined View Controller Interfaces and you'll see that split view controllers aren't supposed to be contained inside any other type of view controller. You're breaking that rule by putting one inside your own view controller, so it's not surprising that it doesn't work well.

0

精彩评论

暂无评论...
验证码 换一张
取 消