gpt4 book ai didi

ios - 当我尝试通过 swift 解雇ViewController 后执行某些功能时,发现为零。

转载 作者:行者123 更新时间:2023-11-30 14:12:33 24 4
gpt4 key购买 nike

从模态视图中解雇ViewController后,我需要刷新背景 View 上的轮播 slider 。

这是我的代码。

在应用程序委托(delegate)上。

class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?
var customDisplayViewController: customInsideViewController?
// this is background view

在背景 View 上。

func refreshCarousel(){
self.carousel.reloadData()
}

在模态视图中

@IBAction func closeModal(sender: AnyObject) {
self.dismissViewControllerAnimated(true, completion: { () -> Void in
let appdelegate = UIApplication.sharedApplication().delegate as! AppDelegate

appdelegate.customDisplayViewController!.refreshCarousel()
//fatal error: unexpectedly found nil while unwrapping an Optional value
})
}

但是我得到了 fatal error :在解包可选值时意外发现 nil完成dismissView后。

所以任何人都知道如何解决这个问题。谢谢!

最佳答案

@罗伯特沃伊塔

我的意思是我已经有了这个。

enter image description here

关于ios - 当我尝试通过 swift 解雇ViewController 后执行某些功能时,发现为零。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31607940/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com