Swift 解决Pushing the same view co

2018-03-28  本文已影响114人  MambaHJ

在要push的地方加一个判断: 要push的ViewController 是否在navigation的顶部

原文是oc代码,于是我修改成了swift代码:

 if (self.navigationController?.topViewController?.isKind(of: TableViewController.self))!{
                self.navigationController?.pushViewController(wordC, animated: true)
            }else{
                NSLog("此处可能会报错")
            }

下面是原文的oc代码:

if(![self.navigationController.topViewController isKindOfClass:[YOURCLASS class]]) {
}

最后贴个Stack Overflow地址:
解决Pushing the same view controller instance more than once is not supported

上一篇下一篇

猜你喜欢

热点阅读