UISpliViewController DetailView旋转后消失

发布于 2024-12-21 21:49:52 字数 1652 浏览 7 评论 0原文

我对 UIViewController 有疑问,请在回答之前先阅读,它比看起来更复杂。无需更改超级 UIViewController 旋转即可正常工作!

我有一个纵向的 UISplitViewController,然后我单击按钮以显示 UIPopoverController 显示弹出框 现在我将 UIViewController 从 UISplitViewC 更改为 UITableViewC tableview 现在我将 iPad 旋转至横向 tableview 风景 最后切换回 SpliViewController! splitviewcontroller 景观 正如您所看到的,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
Popover shown
now i change the UIViewController from UISplitViewC to UITableViewC
tableview
Now i rotate the iPad to Landscape orientation
tableview landscape
And finally switch back to the SpliViewController!
splitviewcontroller landscape
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 技术交流群。

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

发布评论

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

评论(2

心奴独伤 2024-12-28 21:49:52

这里有同样的问题,但是委托的函数肯定会被调用,您可以通过放置 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.

江挽川 2024-12-28 21:49:52

这是很久以前的事了,但据我记得,它就像这里 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

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