这是我的观点的建立:
当UIBarButtonItem
被点击,就应该调出UIImagePickerController
。 我必须这样做使用UIPopoverController
,这是通过点击“重置”按钮调用,因为需要在iPad上。 这里是我的代码:
-(IBAction) btnReset:(id)sender {
[self chooseImage];
}
-(void) chooseImage {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
imagepicker = [[UIImagePickerController alloc] init];
imagepicker.allowsEditing = NO;
imagepicker.delegate = self;
imagepicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagepicker.navigationBar.opaque = true;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
popoverController = [[UIPopoverController alloc] initWithContentViewController:imagepicker];
[popoverController presentPopoverFromBarButtonItem:reset permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
} else {
[self presentModalViewController:imagepicker animated:YES];
}
}
}
但是,如果这就是所谓的观点崩溃与错误:
“NSInvalidArgumentException”的,原因是:“ - [UIPopoverController presentPopoverFromRect:inView:permittedArrowDirections:动画:]:Popovers不能由不具有窗口的图呈现”
我究竟做错了什么? 先感谢您。