我正在使用具有5个UITabBarItem
的选项卡式应用程序。在第二个UITabBarItem
上,我将使用UIImagePickerController
显示相册,但结果是一个奇怪的黑白屏幕(我将其张贴在底部)。
这是我的SecondViewController.h
:
#import <UIKit/UIKit.h>
@interface SecondViewController : UIImagePickerController <UIImagePickerControllerDelegate, UINavigationControllerDelegate>
@end
和
SecondViewController.m
:- (void)viewDidLoad
{
[super viewDidLoad];
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
UIAlertView *noLibraryAlertView = [[UIAlertView alloc] initWithTitle:@"Error"
message:@"No photo library!"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles: nil];
[noLibraryAlertView show];
} else {
self.delegate = self;
self.allowsEditing = NO;
self.navigationBarHidden = NO;
self.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
}
}
但是,当我选择第二个
UITabBarItem
时,应用程序将显示以下内容:有任何想法吗?
提前致谢。
最佳答案
根据apple's documentation,必须以模态形式呈现UIImagePicker:
显示用户界面。在iPhone或iPod touch上,通过调用当前活动视图控制器的presentViewController:animated:completion:方法,以模态方式(全屏)执行此操作,并将配置的图像选择器控制器作为新的视图控制器传递。
因此,它将无法在tabbarcontroller中或作为其他控制器的子代使用。
关于ios - iOS 7-无法在选项卡式应用程序上显示UIImagePickerController,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20334338/