包含的 UISplitView 不发送委托方法

发布于 2024-11-14 07:50:08 字数 1372 浏览 1 评论 0原文

UISplitView 具有以下委托方法,可帮助在旋转期间修改布局:

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

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

这些方法分别由 UISplitView 私有的方法调用,名为 _viewControllerHiding:_updateMasterViewControllerFrame。这两个都是直接从事件循环的顶部调用的,显然是延迟调用。

但是,如果我将自己的视图控制器放置为窗口的根(您不能将分割视图控制器放置在导航控制器中),并将分割视图放置在其下级,则委托方法不会正确发送。 (实际上,在 viewDidLoad 上发送了一个,但在旋转时没有发送。)主视图的隐藏仍然发生,但没有委托喜欢帮助布局(管理弹出框/栏项目)。

我尝试将以下视图控制器方法转发到包含的分割视图,但它们没有触发它。

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

任何人都知道如何触发这些 UISplitView 委托方法吗?最好不是私有 API。

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 popover/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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦冥 2024-11-21 07:50:08

看看 组合视图控制器接口,您会发现分割视图控制器不应该包含在其中任何其他类型的视图控制器。您通过将一个视图控制器放入您自己的视图控制器中来打破该规则,因此它不能正常工作也就不足为奇了。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文