2013-02-17 101 views
0

我的代码中包含presentModalViewController在iOS 4.3及更高版本中存在问题。presentModalViewController for 4.3支持警告

我使用下面的代码时,它是由IOS版本支持使用presentModalViewController和presentViewController。(从后@Stackoverflow两者)

if([self respondsToSelector:@selector(presentViewController:animated:completion:)]) 
    [self presentViewController:myView animated:YES completion:^{/* done */}]; 
else if([self respondsToSelector:@selector(presentViewController:animated:)]) 
    [self presentModalViewController:myView animated:YES]; 
else 
    NSLog(@"Oooops, what system is this !!! - should never see this !"); 

,当我在> 5.0和测试它上面的伟大工程< 5.0。但是在我的AppDelegate.m中,我有一个检查例程,用于检测应用程序是否第一次运行。

如果是,则首先打开一个视图,与启动视图不同。

if (![defaults boolForKey:@"everLaunched"]) { 
    //NSLog(@"First run"); 
if([self.viewController respondsToSelector:@selector(presentViewController:animated:completion:)]) 
     [self.viewController presentViewController:infoView animated:YES completion:^{/* done */}]; 
    else if([self.viewController respondsToSelector:@selector(presentViewController:animated:)]) 
     [self.viewController presentModalViewController:infoView animated:YES]; 
    else 
     NSLog(@"1Oooops, what system is this !!! - should never see this !"); 

}

显然,这是工作,但是当应用程序被启动的第一时间,这恐怕会给我意想不到的错误,在各种设备中我得到一个警告

Unbalanced calls to begin/end appearance transitions for <ViewController: 0x689da90>. 

有什么想法?

回答

0

可能是你应该问的响应presentModalViewController第二个条件,而不是presentViewController

代码

if([self respondsToSelector:@selector(presentViewController:animated:completion:)]) 
    [self presentViewController:myView animated:YES completion:^{/* done */}]; 
else if([self respondsToSelector:@selector(**presentViewController:animated**:)]) 
    [self presentModalViewController:myView animated:YES]; 
else 
+0

Hi和TY为helping.I finnaly通过这个获得通过删除4.3的iOS的支持和感动到5.0 +并仅使用'presentModalViewController'。 – Theodoros80 2013-05-21 17:48:56