【问题标题】:iOS delegate issues when pushing multiple ViewControllers to NavigationController stack将多个 ViewController 推送到 NavigationController 堆栈时的 iOS 委托问题
【发布时间】:2015-11-10 13:37:23
【问题描述】:

我有一些将两个 ViewController 推送到 NavigationController 堆栈的代码。这是因为我想打开菜单的“子菜单”视图。

let menuVC = storyboard!.instantiateViewControllerWithIdentifier("menuView") as! MenuTableViewController
            menuVC.delegate = self

let menuSubVC = storyboard!.instantiateViewControllerWithIdentifier("menuViewSub") as! SubscriptionsTableViewController
            menuSubVC.delegate = menuVC

            controllers?.append(menuVC)
            controllers?.append(menuSubVC)

navigationController?.setViewControllers(controllers!, animated: true)

正如您在代码中看到的,其中涉及一些委托。 menuSubVC 中的一种方法调用 menuVC 中的委托方法,当我尝试将 ImageView 出口设置为新的空图像时,这给了我一个错误:

allCheckmark.image = UIImage()

为什么这不起作用?当我打开菜单然后打开子菜单时,它工作得很好,但是如果我用上面的代码将两者都推送到堆栈中,它就不起作用了。

【问题讨论】:

    标签: ios swift delegates navigationcontroller


    【解决方案1】:

    当您将两者都压入堆栈时,subMenuVC 在下方,因此未加载视图,这意味着未设置任何 IBOutlets。

    【讨论】:

    • 可以加载视图吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多