Warning: Attempt to present on which is already presenting

在iOS 7模拟器上测试没问题。iOS 8.3上报了如下警告:
Warning: Attempt to present on which is already presenting
但是在模拟器上测试:iPhone模拟器上没发现异常,依旧可以选择,在iPad上点击没有反应,还是得解决。

– (IBAction)addAccount:(id)sender
{
UIActionSheet *actionSheet;
pressedIndex = nil;
NSString *privserver = NSLocalizedString(@”xxx”, @”sss”);
if (IsIpad())
actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:privserver, @”www.iganlei.cn”, @”www.iganlei.cn”, nil];
else
actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:NSLocalizedString(@”Cancel”, @”sss”) destructiveButtonTitle:nil otherButtonTitles:privserver, @”www.iganlei.cn”, @”www.iganlei.cn”, nil];
[actionSheet showFromBarButtonItem:sender animated:YES];
}
……

– (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
……

百度了一段解释:
根据问题可以看出ViewController在present UIImagePickerController之前present了UIAlertController,但是,我并没有是用UIAlertView。但是这里出现了UIAlertController这个iOS 8推出的新的类,问题应该就出现在这里。

解决方法:
/* 替换 actionSheet: clickedButtonAtIndex:为下面这个方法 */

– (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{

问题解决。。

未经允许不得转载:ganlei的个人博客 » Warning: Attempt to present on which is already presenting

赞 (1)
分享到:更多 ()