編集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セマンティックの問題が発生します。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){}];
}
}