美文网首页
OC 页面判断Push和Pop

OC 页面判断Push和Pop

作者: 冷煖自知 | 来源:发表于2018-07-10 10:30 被阅读80次
  • 页面消失的时候
- (void)viewWillDisappear:(BOOL)animated {
    NSArray *viewControllers = self.navigationController.viewControllers;//获取当前的视图控制其
    if (viewControllers.count > 1 && [viewControllers objectAtIndex:viewControllers.count-2] == self) {
        //当前视图控制器在栈中,故为push操作
        NSLog(@"push");
    } else if ([viewControllers indexOfObject:self] == NSNotFound) {
        //当前视图控制器不在栈中,故为pop操作
        NSLog(@"pop");
    }
}

相关文章

网友评论

      本文标题:OC 页面判断Push和Pop

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