ios - 了解何时通过手势关闭分屏 View Controller 的主控

标签 ios objective-c ipad uisplitviewcontroller master-detail

我正在 iOS 7 上实现一个主细节应用程序,主视图 Controller 是一个导航 Controller ,可以在两个 TableView Controller 之间导航。细节是一个显示图像的简单 View Controller 。

我已经详细实现了UISplitViewController方法:

- (BOOL) splitViewController:(UISplitViewController *)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation
{
    return UIInterfaceOrientationIsPortrait(orientation);
}

- (void) splitViewController:(UISplitViewController *)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)pc
{
    UINavigationController* nav= (UINavigationController*)aViewController;
    barButtonItem.title= nav.topViewController.title;
    self.navigationItem.leftBarButtonItem= barButtonItem;
}

- (void) splitViewController:(UISplitViewController *)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
{
    self.navigationItem.leftBarButtonItem= nil;
}

问题是,当用户通过手势关闭主视图 Controller 时,不会调用 splitViewController:willHideViewController:withBarButtonItem:forPopoverController:

这种情况下的问题是,如果用户浏览主控的导航 Controller 然后关闭主控,则选项卡栏按钮项目将显示旧标题。

为了更清楚地说明,我将逐步解释发生的情况。主导航 Controller 的根导航 Controller 的标题是“Top Places”。推送的 View Controller 的标题是“照片”。当应用程序启动时,纵向模式下没有母版:

enter image description here

用户呈现“Top Places” View Controller :

enter image description here

然后用户导航到第二个 View Controller :“照片”:

enter image description here

然后用户关闭主控,但选项卡栏按钮项仍保留其旧标题“Top Places”:

enter image description here

问题在于,当通过手势关闭主 Controller 时,分割 View Controller 委托(delegate)没有调用的方法。

最佳答案

根本没有 UISplitViewControllerDelegate 委托(delegate)方法来检测纵向弹出窗口何时关闭。如何被驳回并不重要。如果您想知道,请为弹出窗口 Controller 设置一个委托(delegate)。

当您从横向旋转到纵向时,将调用 splitViewController:willHideViewController:withBarButtonItem:forPopoverController: 委托(delegate)方法。

关于ios - 了解何时通过手势关闭分屏 View Controller 的主控,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22702557/

相关文章:

objective-c - 带有 ModalPresentationStyle 的 Popover 在 iOS 7 iPad 中不居中

objective-c - UIView.center = UIImageView.center 但 ImageView 似乎不在横向中心

ios - 如何摆脱额外的状态栏?

基于 iOS Tile 的 View 导航 Controller

iOS 核心数据 : How do I add subsequent records to the 'many' of 1:many relationships?

ios - 如何使用系统音量来播放声音?

ios - 如何在 iOS 中构建网络特定应用程序(IP 映射)?

ios - Iphone - 当每个单元格高度是动态的时,何时计算 tableview 的 heightForRowAtIndexPath?

iphone - UIWebView 加载数据和 iWork 文件

objective-c - Restkit 对象映射两个类访问错误