当前位置:首页 > 技术心得 > 正文内容

navigationController的pushViewController无效问题

xjtudll10年前 (2016-07-31)技术心得18530

参考资料:http://www.cocoachina.com/ask/questions/show/52842

我觉得这个问题很有代表性,尤其是小白,所以将重点内容摘抄过来了。

问题及操作过程:

1、新建一个 single View Application,会自动给我生成一个带xib的文件,就是默认的起始界面。 然后在xib里面加一个btn,以及触发事件onClick
2、新建一个 UIViewController,叫做pageFirst。

3、在默认的起始界面的onClick方法里面写:

- (IBAction)onClick:(id)sender

{

     pageFirst *firstview = [[pageFirst alloc] initWithNibName:@"pageFirst" bundle:nil];

     [self.navigationController pushViewController:firstview animated:YES];

}

界面没有发生变化,但是程序确实被运行了,也没有报错,然后论坛也有好多人问过,但是都没有解决我这个问题

原因:

navigationController是假的,并没有实例化,只是放在了view上而已。需要实例化或者关联起来。

实例化如下:

UINavigationController   *nav = [UINavigationController alloc]initWithRootController:....]

这个函数去试一下,然后presentModalViewController

扫描二维码推送至手机访问。

版权声明:本文由鸟的天空发布,如需转载请注明出处。

本文链接:http://xjtudll.cn/Exp/413/

标签: ios
分享给朋友:

“navigationController的pushViewController无效问题” 的相关文章

金蝶K3:自定义的万能报表位置

金蝶K3:自定义的万能报表位置

场景:客户再【会计总账管理系统】开发了一个万能报表【AAA】 后来因工作交接或者某些原因忘记这个AAA报表放在哪个子系统下了,由于K3子系统非常多,要逐个切换子系统来找自己建立的万能报表再哪里;非常麻烦:使用下面这段脚本查询:select b.FName,* from t_UserDefineRpt...

如何通过程序清除蓝牙缓存的设备名称?

http://stackoverflow.com/questions/10793761/how-to-programmatically-clear-the-bluetooth-name-cache-in-android 现象: 一个已经配对过的蓝牙设备,修改名称之后,手机上显示的依旧是以前的名称,并...

ios7 xib适配statusBar—同时适配ios7和ios6

ios7 xib适配statusBar—同时适配ios7和ios6

参考资料:https://developer.apple.com/library/ios/documentation/userexperience/conceptual/TransitionGuide/SupportingEarlieriOS.html ios7中,由于status b...

error 65: access violation at 0x40021000 : no 'read' permission

error 65: access violation at 0x40021000 : no 'read' permission

经过测试发现,该办法仅仅适合STM32F103,对于STM32F107,即使这样修改,还是提示同样的error的。 我是在Win7 64bit下实验的 以下是参考资料: https://blog.csdn.net/beready/article/details/24668529 开发环境:keil...

Quartus CPLD未使用引脚处理

Quartus CPLD未使用引脚处理

未使用的引脚可以设置成输出,三态输入,弱上拉输入等。Quartus 8.0默认设置成输出低电平(As output driving ground)。 引脚设置方法: 【Assignments】->【Setting】->【Device】->【Device and Pin Option...

Xcode Error:loaded some nib but the view outlet was not set解决

Xcode Error:loaded some nib but the view outlet was not set解决

当使用 initWithNibName 函数, 并使用由nib文件生成的ViewController 的view属性时候,遇到这个问题。 *** Terminating app due to uncaught exception 'NSInternalInconsistencyException'...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。