iOS 如何判断当前页面是push进入还是present进入

把.h 中自定义的nav全局属性删除掉吧,每次跳转都需要赋值,

下面的方法可以实现,就不用再占用内存资源。


图片

代码区域

/// 返回 iOS 如何判断当前页面是push进入还是present进入

- (void)did

{

    NSArray *viewcontrollers = self.navigationController.viewControllers;

    if (viewcontrollers.count > 1)

    {

        if ([viewcontrollers objectAtIndex:viewcontrollers.count - 1] == self)

        {  //push方式

            XPFLog(@"push方式"); [self.navigationController popViewControllerAnimated:YES];

        }

    }

    else

    {  //present方式

        XPFLog(@"present方式");[self.navigationController dismissViewControllerAnimated:YES completion:nil];

    }

}


你可能感兴趣的:(iOS 如何判断当前页面是push进入还是present进入)