编辑 - 我自己解决了这个问题 - 请参阅底部的注释
在 Xcode 5 上使用 iOS7 时,我使用一个选项从相机或照片库中拍摄图像,一旦选择了图像(或拍摄了一张新照片),视图应该翻转到下一个屏幕。
这在运行 iOS7 的 iPhone 上不会发生,它在 iPad 上运行良好,但方法略有不同,但它似乎是 iOS7 上唯一的 iPhone 问题。
这是使用的代码,例如,从库函数中选择图像;
-(void) choosePic {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum]) {
UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
cameraUI.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
cameraUI.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType: UIImagePickerControllerSourceTypeSavedPhotosAlbum];
cameraUI.allowsEditing = NO;
cameraUI.delegate = self;
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
_popover = [[UIPopoverController alloc] initWithContentViewController:cameraUI];
[_popover presentPopoverFromRect:btnLibrary.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
else
[self presentModalViewController: cameraUI animated: YES];
}
}
此外,选择器完成后的代码;
- (void) imagePickerController: (UIImagePickerController *) picker didFinishPickingMediaWithInfo: (NSDictionary *) info {
//Disable buttons
[[UIApplication sharedApplication] setStatusBarHidden:YES];
[self disableButtons];
//Get image
self.originalImage = (UIImage *) [info objectForKey: UIImagePickerControllerOriginalImage];
//Dismiss
if(_popover)
{
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
[_popover dismissPopoverAnimated:YES];
_popover = nil;
}
}
else
[picker dismissModalViewControllerAnimated: YES];
//Next
[self performSelector: @selector(nextScreen) withObject:nil afterDelay:0.5];
}
我通过切换解决了这个问题;
[picker dismissModalViewControllerAnimated: YES];
和
[picker dismissViewControllerAnimated:NO completion:nil];