判断当前viewcontroller是push还是present
2018-02-23 本文已影响67人
二先生Developer
NSArray *viewcontrollers = self.navigationController.viewControllers;
if (viewcontrollers.count > 1) {
if ([viewcontrollers objectAtIndex:viewcontrollers.count - 1] == self) { //push方式
[self.navigationController popViewControllerAnimated:YES];
}
}
else { //present方式
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
}