0

编辑 0

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.overlayViewController = [[BSsetupOverlayViewController alloc] initWithNibName:@"BSsetupOverlayViewController" bundle:nil] ;

    // as a delegate we will be notified when pictures are taken and when to dismiss the image picker
    self.overlayViewController.delegate = self;

    if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
    {
        // camera is not on this device, don't show the camera button
        NSMutableArray *toolbarItems = [NSMutableArray arrayWithCapacity:self.myToolbar.items.count];
        [toolbarItems addObjectsFromArray:self.myToolbar.items];
        [toolbarItems removeObjectAtIndex:2];
        [self.myToolbar setItems:toolbarItems animated:NO];
    }

    [self showImagePicker:UIImagePickerControllerSourceTypeCamera];
}

编辑 0

下面的-showImagePicker:代码几乎与 PhotoPicker 示例完全相同,只是第一个注释掉的行被它上面的行替换(因为不推荐使用的功能)。但是,该行的新版本正在产生警告Warning: Attempt to present <UIImagePickerController: 0x1c53ec70> on <BSsetupViewController: 0x1d888c10> whose view is not in the window hierarchy!

另一方面,如果我将第一个注释掉的行替换为它下面的行,我会遇到 ARC Semantic 问题No visible @interface for 'BSsetupViewController' declares the selector 'presentModalViewController:animated:completion:'

有任何想法吗?

- (void)showImagePicker:(UIImagePickerControllerSourceType)sourceType
{
    if (self.imageView.isAnimating)
        [self.imageView stopAnimating];

    if (self.capturedImages.count > 0)
        [self.capturedImages removeAllObjects];

    if ([UIImagePickerController isSourceTypeAvailable:sourceType])
    {
        [self.overlayViewController setupImagePicker:sourceType];
        [self presentViewController:self.overlayViewController.imagePickerController animated:YES completion:^(void){}];
      //[self presentModalViewController:self.overlayViewController.imagePickerController animated:YES];
      //[self presentModalViewController:self.overlayViewController.imagePickerController animated:YES completion:^(void){}];

    }
}
4

0 回答 0