怎么判断viewcontroller是Push还是Pop?
怎么判断viewcontroller是Push还是Pop?
新风作浪一般情况下判断viewcontroller在返回时需要push还是pop都会在.h
文件带一个参数进来。如何让容器自己判断?
方法一
NSArray* views = [self.navigationController viewControllers];
BOOL variable = [views containsObject: self];
if (variable) {
[self.navigationController popViewControllerAnimated:YES];
}
else {
[self dismissViewControllerAnimated:YES completion:^{}];
}
方法二
if (self.navigationController != nil) {
[self.navigationController popViewControllerAnimated:YES];
}else{
[self dismissViewControllerAnimated:YES completion:^{}];
}
评论
匿名评论隐私政策