一个控制器可能是Modal出来的,也可能是push出来的,这样返回就需要不同的方法
在按钮的回调中,实现下面的方法.
- (void)dismissBtnPressed:(id)sender {
if (self.navigationController) {
if (self.navigationController.viewControllers.count == 1) {
[self.navigationController dismissModalViewControllerAnimated:YES];
} else {
[self.navigationController popViewControllerAnimated:YES];
}
} else {
[self dismissModalViewControllerAnimated:YES];
}
}