UISpliViewController DetailView旋转后消失
我对 UIViewController 有疑问,请在回答之前先阅读,它比看起来更复杂。无需更改超级 UIViewController 旋转即可正常工作!
我有一个纵向的 UISplitViewController,然后我单击按钮以显示 UIPopoverController 现在我将 UIViewController 从 UISplitViewC 更改为 UITableViewC
现在我将 iPad 旋转至横向
最后切换回 SpliViewController!
正如您所看到的,MasterViewController 没有显示,NavigationItem 也没有消失。
这让我假设在 UITableViewController 的旋转上不会调用 splitview 的委托函数(毫不奇怪)
我该如何处理这个问题?
委托功能
- (void)splitViewController: (UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc {
//debug_NSLog(@"Entering portrait, showing the button: %@", [aViewController class]);
barButtonItem.title = @"Akten";
[self.navigationItem setLeftBarButtonItem:barButtonItem animated:YES];
[self setMasterPopover: pc];
}
// Called when the view is shown again in the split view, invalidating the button and popover controller.
- (void)splitViewController: (UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {
//debug_NSLog(@"Entering landscape, hiding the button: %@", [aViewController class]);
[self.navigationItem setLeftBarButtonItem:nil animated:NO];
[self setMasterPopover: nil];
}
感谢您的帮助!
I have a issue with the UIViewController, please first read before you answer, it is more complicated than it seems. Without Changing the super UIViewController rotation works without problems!
I have a UISplitViewController in Portrait orientation, than i klick on the Button to show the UIPopoverController
now i change the UIViewController from UISplitViewC to UITableViewC
Now i rotate the iPad to Landscape orientation
And finally switch back to the SpliViewController!
As you can see, the MasterViewController isn't showed and the NavigationItem doesn't disappear.
That brings me to the assumption that the delegate function of the splitview aren't called on the rotation of the UITableViewController (no surprise)
How can i handle this issue?
Delegate functions
- (void)splitViewController: (UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc {
//debug_NSLog(@"Entering portrait, showing the button: %@", [aViewController class]);
barButtonItem.title = @"Akten";
[self.navigationItem setLeftBarButtonItem:barButtonItem animated:YES];
[self setMasterPopover: pc];
}
// Called when the view is shown again in the split view, invalidating the button and popover controller.
- (void)splitViewController: (UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {
//debug_NSLog(@"Entering landscape, hiding the button: %@", [aViewController class]);
[self.navigationItem setLeftBarButtonItem:nil animated:NO];
[self setMasterPopover: nil];
}
Thanks for your Help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这里有同样的问题,但是委托的函数肯定会被调用,您可以通过放置 NSLog 来检查
另一种方法是制作你自己的弹出控制器和在 didrotate 方法中调用它。
Same issue here but the delegate's function are being called for sure,you can check that by putting NSLog
Other way around make your own popovercontroller & call it in didrotate method.
这是很久以前的事了,但据我记得,它就像这里 stackoverflow.com/questions/4649617/...
您的主视图控制器需要实现接收 splitview 委托并将其转发到 splitview,即使它不可见。
不能保证,就像我很久以前说的
It is too long ago but as long as I can remember it was something like here stackoverflow.com/questions/4649617/…
You master view controller needs to implement receive the splitview delegate and forward it to the splitview even if it is not visible.
No guarantee, like I said, long time ago