模态跳转和push跳转到公共页面如何返回
来源:互联网 发布:没有网络怎么安装驱动 编辑:程序博客网 时间:2024/06/03 19:39
[self presentViewController:<#(nonnull UIViewController *)#> animated:<#(BOOL)#> completion:<#^(void)completion#>]
返回时使用对应的返回方法
[selfdismissViewControllerAnimated:YEScompletion:nil];
push跳转页面使用
[self.navigationController pushViewController:<#(nonnull UIViewController *)#> animated:<#(BOOL)#>]
对应的返回方法为
[self.navigationControllerpopViewControllerAnimated:YES];
这里提出一个场景:从页面A可以模态跳转到公共页面M,从页面B也可以push跳转到页面M,那么页面M相应的返回按钮应该怎么实现,这里我给出一个解决方案:
给公共页面M声明一个属性:
@property (nonatomic,assign) BOOL mark;
//a.从页面A跳转到公共页面M
M * mainDetailVC = [[M alloc]init];
mainDetailVC.mark = YES;
UINavigationController *navc = [[UINavigationControlleralloc]initWithRootViewController:mainDetailVC];
[selfpresentViewController:navc animated:YEScompletion:nil];
//b.从页面B跳转到公共页面MM * mainDetailVC = [[Malloc]init];
[self.navigationControllerpushViewController:mainDetailVC animated:NO];
最后一步:在控制器M中实现返回按钮,需要两种返回方法
- (void)viewWillAppear:(BOOL)animated {
//判断是模态过来的还是push过来的,对应创建相应的返回按钮及方法
if (self.mark ==YES) {
UIBarButtonItem *btn = [[UIBarButtonItemalloc]initWithTitle:@"返回"style:(UIBarButtonItemStylePlain)target:selfaction:@selector(clickback:)];
self.navigationItem.leftBarButtonItem = btn;
}
else {UIBarButtonItem *btn = [[UIBarButtonItemalloc]initWithTitle:@"返回"style:(UIBarButtonItemStylePlain)target:selfaction:@selector(clickbacktwo:)];
self.navigationItem.leftBarButtonItem = btn;
}
}
//模态返回方法,如果是模态过来的就会使用此方法返回
- (void)clickback:(UIBarButtonItem *)but {
[selfdismissViewControllerAnimated:YEScompletion:nil];
}
//pop返回方法,如果是push过来的就会使用此方法
- (void)clickbacktwo:(UIBarButtonItem *)but {
[self.navigationControllerpopViewControllerAnimated:YES];
}
- 模态跳转和push跳转到公共页面如何返回
- 页面跳转和返回
- modal push 跳转返回
- IOS - 页面跳转及返回 (push-pop,modal-dismiss)
- iOS层级跳转(UINavigationController跳转返回到指定的页面)
- 模态页面跳转到下一页
- UINavigationController及页面跳转、push
- Meego touch实现页面跳转和返回
- Meego touch实现页面跳转和返回
- Intent实现页面的跳转和返回
- 页面跳转返回问题
- Android跳转返回页面
- 跳转页面并返回
- php如何跳转到其他页面
- 如何跳转到app的设置页面
- ios ViewController生命周期 ---- push跳转和模态跳转的VC生命周期
- 从fragment跳转到activity , 返回到指定fragment页面
- page页面跳转到子页面和category页面跳转到子页面有区别:
- ubuntu软件安装三 xampp phpstorm
- mac分辨率设置
- 算法训练 连续正整数的和
- 得到栈的最小元素
- 基于S3C6410的ARM11学习(三) 核心初始化之设置中断向量表
- 模态跳转和push跳转到公共页面如何返回
- Swift-常量与变量
- hibernate映射(五)——继承映射
- angular 表单验证 遇到问题总结
- KMP字符串查找算法
- jsp状态管理(Cookie Session)学习笔记整理
- Linux TCP/IP Socket编程
- Android典型界面设计(8) ——ViewPager+PagerSlidingTabStrip实现双导航
- ES插入更新操作