uinavigationcontroller – UISplitViewController中对开始/结束外观转换的不平衡调用

前端之家收集整理的这篇文章主要介绍了uinavigationcontroller – UISplitViewController中对开始/结束外观转换的不平衡调用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我的UISplitViewController基本上像魅力一样工作,除了在第一次(仅第一次!)从主表视图转换到详细视图时显示恼人的错误消息.
Unbalanced calls to begin/end appearance transitions for <UINavigationController: 0x160015600>.

主视图和详细视图控制器都嵌入在UINavigationController中.但是,只有在设置以下内容时才会出现错误(这是iPhone上逻辑行为所必需的):

class MySplitViewController: UISplitViewController,UISplitViewControllerDelegate {
    override func viewDidLoad() {
        super.viewDidLoad()
        self.delegate = self
    }

    func splitViewController(splitViewController: UISplitViewController,collapseSecondaryViewController secondaryViewController: UIViewController,ontoPrimaryViewController primaryViewController: UIViewController) -> Bool {
        return true
    }
}

如果有人能提供这个问题的解决方案,那将是很好的,在此先感谢.

BTW:拆分视图控制器已在故事板中设置

呈现详细视图控制器是在tableView:didSelectRowAtIndexPath:方法中完成的,如下所示:

if let detailViewController = delegate as? DetailViewController {
    detailViewController.navigationItem.leftItemsSupplementBackButton = true
    detailViewController.navigationItem.leftBarButtonItem = splitViewController!.displayModeButtonItem()
    splitViewController!.showDetailViewController(detailViewController.navigationController!,sender: self)
}

解决方法@H_502_18@
最有可能的是,您在UISplitViewController中从master(UITableController中的UITableView?)到详细(UIViewController)视图的第一次转换在活动/当前视图完成显示之前启动.

可能的原因是您可能尝试在主UIViewController的viewDidLoad()方法中呈现详细视图的第一个“实例”?在这种情况下,您应用可能会尝试在主视图完成显示之前显示详细信息视图.请注意,视图之间的区别确实加载了视图并且确实显示了视图:

override func viewDidLoad()

Description:

Called after the controller’s view is loaded into memory.

This method is called after the view controller has loaded its view
hierarchy into memory
.


override func viewDidAppear(animated: Bool)

Description:

Notifies the view controller that its view was added to a view
hierarchy
. You can override this method to perform additional tasks
associated with presenting the view.

现在,由于您的问题未显示如何加载初始详细信息视图,因此您可能已经注意到以下建议,但无论如何:如果您的详细视图是从viewDidLoad()呈现的,请尝试将其移至viewDidAppear( ) 方法

override func viewDidAppear(animated: Bool) {
    super.viewDidAppear(true)

    // present/load detail view here instead
}

猜你在找的iOS相关文章