美文网首页
iOS 区分页面是push还是pop

iOS 区分页面是push还是pop

作者: 夜之海澜 | 来源:发表于2019-10-14 16:05 被阅读0次

在开发中我们有时候会需要区分页面的出现和消失是push进来的,还是pop回来的,或者是present的,还是dismiss的。
那么在页面即将出现或者即将消失的时候我们用以下代码进行区分即可:

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    if ([self isBeingDismissed] || [self isMovingFromParentViewController]) {
        //pop 或者dismiss操作
    } else {
        // push 或者 present
    }
}

相关文章

网友评论

      本文标题:iOS 区分页面是push还是pop

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