http://broadcast.oreilly.com/2009/06/tab-bars-and-navigation-bars-t.html
在第一个标签中,我有一个带有两个按钮的标准UIVIEw.两者都调用相同的函数来显示UIImagePickerController:
-(IBAction) btnPhotoClicked:(ID)sender {UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];imagePicker.delegate = self;if((UIbutton *)sender == btnChoosePhoto){ imagePicker.allowsEditing = YES; imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;} else { imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;}[self presentModalVIEwController:imagePicker animated:YES];[imagePicker release];}
我在模拟器中运行代码,所以只需单击“选择照片”按钮.当对话框与所选照片一起发布时,此功能运行:
-(voID)imagePickerController:(UIImagePickerController *)picker dIDFinishPickingMediawithInfo:(NSDictionary *)info {NSURL *mediaUrl;mediaUrl = (NSURL *)[info valueForKey:UIImagePickerControllerMediaURL];if (mediaUrl == nil){ imagePuzzle = (UIImage *) [info valueForKey:UIImagePickerControllerEditedImage]; if(imagePuzzle == nil) { //--- Original Image was selected --- imagePuzzle = (UIImage *) [info valueForKey:UIImagePickerControllerOriginalimage]; } else { //--- Get the edited image --- //--- If it was successful the above valueForKey:UIImagePickerControllerEditedImage //--- would have assigned it already. }}else { //--- Muppet selected a vIDeo}// Animate the picker window going away[picker dismissModalVIEwControllerAnimated:YES];ImageVIEwController *imageVIEwController = [[ImageVIEwController alloc] init];imageVIEwController.delegate = self; [self presentModalVIEwController:imageVIEwController animated:YES];[imageVIEwController release];}
这就是我的问题所在.我尝试了很多不同的黑客和迭代,但上面的代码是最简单的问题.当imageVIEwController显示为模式对话时,抛出以下异常:
2010-07-09 15:29:29.667 Golovomka[15183:207] *** Terminating app due to uncaughtexception 'NSInternalinconsistencyException',reason: 'Attempting to begin a modalTransition from <NewVIEwController: 0x5915f80> to <ImageVIEwController: 0x594a350> while a Transition is already in progress. Wait for vIEwDIDAppear/vIEwDIDdisappearto kNow the current Transition has completed'
我该如何解决这个问题?我尝试过延迟和其他技巧,但是我真的不明白我应该如何使用vIEwDIDAppear或vIEwDIDdisappear来帮助我.另外值得注意的是,一个非常基本的应用程序,其中一个视图加载选择器,然后显示另一个带有图像的视图,不会产生错误.任何帮助感激不尽.
解决方法 要解决此处描述的特定问题,您可以在类中添加vIEwDIDAppear方法:-(voID)vIEwDIDAppear:(BOol)animated{ if (/*just visited ImagePicker*/) { ImageVIEwController *imageVIEwController = [[ImageVIEwController alloc] init]; imageVIEwController.delegate = self; [self presentModalVIEwController:imageVIEwController animated:YES]; [imageVIEwController release]; }}
从通话下方删除这些行:
[picker dismissModalVIEwControllerAnimated:YES];
因此,每当你的类出现(显示)时,它将调用vIEwDIDAppear …因为这很可能不是你想要的所有时间,你可以添加一些变量来设置/清除定义是否立即显示self时显示imageVIEwController.像“如果来自图像选择器,显示imageVIEwController,否则什么也不做”.
也就是说,imho,推动模态视图通常应该响应用户 *** 作而完成,我可能会在这里重新考虑用户体验 – 例如添加一个子视图,而不是推动你可以在当前拥有代码的地方进行模态视图 – 但是如果你只是在玩一些应该解决NSInternalinconsistencyException的教程. :)干杯!
总结以上是内存溢出为你收集整理的iPhone应用程序中的例外情况:模态转换已在进行中全部内容,希望文章能够帮你解决iPhone应用程序中的例外情况:模态转换已在进行中所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)