storyboard presentViewController pushViewController 跳转后黑屏 NavigationBar按钮push
2014-08-11 11:34
447 查看
环境:XCode5.1,iOS6样式,Storeboard
先在主页面建一个navigation view,然后在导航栏放了一个button,也称之为bar button item.
新建一个view controller(简称viewB),结果按住ctrl,拖动button到viewB可以建立Modal或者Push,运行就是没反应!
好吧,那就创建一个button的action,我习惯用VC++的命名:
- (IBAction)onBtnShowModal2:(id)sender {
}
这样仿真时可以发现按钮事件是调用的,那就可以用代码来跳转到ViewB啦。实现之:
结果发现,导航栏出现了,但是界面黑屏了!使用
[self presentViewController:view animated:YES completion:nil];
结果全部黑屏
好了,换一种方法:
点选ViewB的ViewController,然后右边identity inspector设置Storyboard ID,例如“RightWin”
这下OK了,就是创建view时的不一样!
使用[self presentViewController:view animated:YES completion:nil];也OK了,不过是全屏不带navigation bar的。可以使用
[self dismissViewControllerAnimated:YES completion:nil];返回!!!
//============华丽的分割线==============
其实上面说了那么多,无非证明一件事:拖动过去的button是可以用的,如果想实现导航栏按钮的导航功能,那这个做法就很傻逼了!正确做法如下:
把button换成bar button item(在控件的最下面),这样按住ctrl拖动,选择push就OK啦,一句话也不用写,是不是很傻逼?哈哈
先在主页面建一个navigation view,然后在导航栏放了一个button,也称之为bar button item.
新建一个view controller(简称viewB),结果按住ctrl,拖动button到viewB可以建立Modal或者Push,运行就是没反应!
好吧,那就创建一个button的action,我习惯用VC++的命名:
- (IBAction)onBtnShowModal2:(id)sender {
}
这样仿真时可以发现按钮事件是调用的,那就可以用代码来跳转到ViewB啦。实现之:
//导航栏按钮弹出模态窗体 - (IBAction)onBtnShowModal2:(id)sender { //用pushviewcontroller可以出现导航栏,自动有返回按钮,黑屏 RightBtnViewController *view = [[RightBtnViewController alloc] init]; [self.navigationController pushViewController:view animated:YES]; }
结果发现,导航栏出现了,但是界面黑屏了!使用
[self presentViewController:view animated:YES completion:nil];
结果全部黑屏
好了,换一种方法:
点选ViewB的ViewController,然后右边identity inspector设置Storyboard ID,例如“RightWin”
//导航栏按钮弹出模态窗体 - (IBAction)onBtnShowModal2:(id)sender { RightBtnViewController *view = [self.storyboard instantiateViewControllerWithIdentifier:@"RightWin"]; [self.navigationController pushViewController:view animated:YES]; }
这下OK了,就是创建view时的不一样!
使用[self presentViewController:view animated:YES completion:nil];也OK了,不过是全屏不带navigation bar的。可以使用
[self dismissViewControllerAnimated:YES completion:nil];返回!!!
//============华丽的分割线==============
其实上面说了那么多,无非证明一件事:拖动过去的button是可以用的,如果想实现导航栏按钮的导航功能,那这个做法就很傻逼了!正确做法如下:
把button换成bar button item(在控件的最下面),这样按住ctrl拖动,选择push就OK啦,一句话也不用写,是不是很傻逼?哈哈
相关文章推荐
- storyboard presentViewController pushViewController 跳转后黑屏 NavigationBar按钮push
- 界面跳转之presentViewController、pushViewController
- storyboard pushViewController 的时候,新的界面黑屏
- ios presentViewController:destinationView跳转后黑屏问题
- Swift中使用presentViewController跳转页面后模拟器显示黑屏问题
- 关于使用模态窗口presentViewController跳转黑屏的解决
- pushViewController, popViewController, presentViewController, dismissViewController---关于视图跳转的总结
- iOS presentViewController 跳转黑屏现象解析
- presentViewController和pushViewController ---关于视图跳转的总结
- presentViewController和pushViewController ---关于视图跳转的总结
- ios presentViewController:destinationView跳转后黑屏问题
- pushViewController, popViewController, presentViewController, dismissViewController---关于视图跳转的总结
- iOS 【iOS ViewController的跳转形式 Present ViewController Modally】
- 解决presentViewController的延迟跳转问题
- presentViewController 、pushViewController和presentModalViewController
- 使用presentViewController跳转时,页面黑色
- iOS实现点击按钮,跳转到与mian.storyboard 中与ViewController 关联的页面
- 使用presentViewController跳转到上上个页面,实现多层跳转的两种方法。
- pushViewController和presentViewController的区别
- ios开发navigationController pushViewController 方式多次跳转 怎么返回到最上层,怎么返回到指定的某一层