我正在使用具有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/

10-12 00:31
查看更多