IOS6.0 控制器展现方式总结

本文介绍了在iOS应用中如何使用UINavigationController进行页面间的导航,包括控制器的展示(模态和推入)与移除(关闭模态和弹出)。通过具体的代码示例展示了不同场景下的实现方式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. modal a controller
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
ControllerA *ca = [storyboard instantiateViewControllerWithIdentifier:@"ControllerA"];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:ca];
ca.modalPresentationStyle = UIModalPresentationFullScreen;// 全屏视图显示
ca.modalTransitionStyle = UIModalTransitionStyleCoverVertical;// 从下向上滑出
// modal
[self presentViewController:nav animated:YES completion:NULL];

2. dismiss a modal controller

[self dismissViewControllerAnimated:YES completion:NULL];


3. push a controller

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
ControllerA *ca = [storyboard instantiateViewControllerWithIdentifier:@"ControllerA"];
// push
[self.parentViewController.navigationController pushViewController:ca animated:YES];


4. pop a controller

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
ControllerA *ca = [storyboard instantiateViewControllerWithIdentifier:@"ControllerA"];

UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:ca];
popover.popoverContentSize = CGSizeMake(320, 480);
// pop
[popover presentPopoverFromBarButtonItem:item
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];


5. dismiss a pop controller

[self.popover dismissPopoverAnimated:YES];

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值