0

我的代码中有一个问题,即在 iOS 4.3 及更高版本中包含 presentModalViewController。

当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.mi 中有一个检查例程,用于检测应用程序是否第一次运行。

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

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>.

任何想法?

4

1 回答 1

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
于 2013-05-21T07:57:26.757 回答