我在iPad上为image picker
创建了一个弹出框。这个功能有效。但如果按两次UIBarButton
,应用程序崩溃。
@property (retain) UIPopoverController *popoverController1;
-(IBAction)photos:(id)sender {
test = false;
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.wantsFullScreenLayout = NO;
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.allowsEditing = YES;
self.popoverController1 = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
_popoverController1.delegate = self;
[_popoverController1 setPopoverContentSize:CGSizeMake(1024, 500)];
[self.popoverController1 presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
你有什么建议吗?
答案 0 :(得分:2)
您可能需要检查弹出窗口是否可见。如果您已创建其对象,则将其关闭并再次创建popover
if ([self.popoverController isPopoverVisible]) {
[self.popoverController dismissPopoverAnimated:YES];
[popoverController setDelegate:nil];
[popoverController release]; // Use release only if , it is without ARC
}
else
{
// Create popover and assign its properties.
}
这肯定会解决您在所有iOS版本中的问题。 :)有一个快乐的编码。!!