控制器的跳转方法
程序员文章站
2022-07-08 10:50:32
...
在开发过程中,经常会遇到这样跳转,在自定义view、AppDelegate等地方,用push、present不能正常的跳转。我总结了三种方法。如果有其他更好的处理方式,记得告诉我哦!!!
#pragma mark ---- 跳转控制器的方法 ---
-(void)jumpViewController
{
MoreViewController *more = [[MoreViewController alloc]init];
UIApplication *app =[UIApplication sharedApplication];
AppDelegate *app2 = app.delegate;
UINavigationController *nav =[[UINavigationController alloc]initWithRootViewController:more];
app2.window.rootViewController = nav;
app2.window.rootViewController.modalTransitionStyle = UIModalTransitionStylePartialCurl;
}
//跳转控制器的方法2
-(void)jumpViewController2
{
ProjectDetailsViewCtl *vc = [[ProjectDetailsViewCtl alloc]init];
UINavigationController *nav =[[UINavigationController alloc]initWithRootViewController:vc];
nav.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
//[self.window.rootViewController presentViewController:nav animated:YES completion:nil];
[self presentViewController:nav animated:YES completion:nil];
}
-(void)navLeftBarAction {
// 返回 用dismiss
[self dismissViewControllerAnimated:YES completion:nil];
}
//跳转控制器的方法2
-(void)jumpViewController3
{
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:vc animated:YES completion:nil];
}