在自定义的view中有点击事件需要push到下一个控制器,但是在view中不能用下面这个方法
[self.navigationController pushViewController:nextVc animated:YES];
正确的push方法是这样的
//取出根视图控制器
UITabBarController *tabBarVc = (UITabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController;
//取出当前选中的导航控制器
UINavigationController *Nav = [tabBarVc selectedViewController];
[Nav pushViewController:nextVc animated:YES];
present(模态)到另外一个控制器
MLLoginViewController *loginVc = [MLLoginViewController instance];
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:loginVc animated:YES completion:nil];
return;
转载:http://blog.csdn.net/ws1352864983/article/details/53787418