美文网首页iOS技术
Pushing the same view controller

Pushing the same view controller

作者: 请叫我_大斌 | 来源:发表于2016-03-16 21:47 被阅读2249次

问题:在调用pushViewController的时候程序崩溃

应用有这样一个功能,点击推送通知可以跳转到对应的一个消息界面,
但这个界面是从另一个Controller Push进来的,所以,问题来了,当我已经在APP中手动打开了这个消息界面时,我再去点击通知栏的消息,这时会再次调用这个push方法,于是程序就会崩溃,
报错:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing the same view controller instance more than once is not supported 。。。。'

所以在push之前先做个判断:

    if(![self.navigationController.topViewController isKindOfClass:[_pageController class]]) {
        [self.navigationController pushViewController:_pageController animated:YES];
    }

问题解决😄😄😄

原文链接
My Page

相关文章

网友评论

    本文标题:Pushing the same view controller

    本文链接:https://www.haomeiwen.com/subject/przqlttx.html