现在的位置: 首页 > 综合 > 正文

ios下presentModalViewController产生的错误。

2013年08月26日 ⁄ 综合 ⁄ 共 674字 ⁄ 字号 评论关闭

在调试代码的时候,遇到这样的一种情况, 用model方式弹出一个 controller. 代码如下

systemstyleViewController * s = [[systemstyleViewController
alloc]init];

    UINavigationController *nav = [[UINavigationController
alloc] initWithRootViewController:s];  

    s.modalPresentationStyle =
UIModalPresentationFormSheet ;

    s.modalTransitionStyle =
UIModalTransitionStyleFlipHorizontal ;

    [self
presentModalViewController:s animated:YES] ;


曝出的错误是

Application tried to present modally an active controller

如果把UINavigationController这行屏蔽掉后,程序能正常运行。 

//  UINavigationController *nav = [[UINavigationController allocinitWithRootViewController:s];


猜想可能是生成Navigationcontroller后,系统就认为它是active的了

但是push却可以

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

抱歉!评论已关闭.