iOS判断当前ViewController是push还是present方式显示的

2025-04-24 01:05:59
推荐回答(1个)
回答1:

if ([self respondsToSelector:@selector(dismissViewControllerAnimated:completion:)]) {
//判断1
[self dismissViewControllerAnimated:YES completion:nil];
} else if ([self.navigationController respondsToSelector:@selector(popViewControllerAnimated:)]) {
//判断2
[self.navigationController popViewControllerAnimated:YES];