图像选择器暂时出现在iPad上

时间:2011-03-13 10:16:10

标签: objective-c ios ipad uiimagepickercontroller

我有以下代码:

UIImagePickerController* picker = [[UIImagePickerController alloc] init]; 
        picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
        picker.delegate = self; 

        popover = [[UIPopoverController alloc] initWithContentViewController:picker];
        popover.delegate = self;
        [popover presentPopoverFromRect:self.view.frame
                                 inView:self.view
               permittedArrowDirections:UIPopoverArrowDirectionAny
                               animated:YES];
        [picker release];

它应该在iPad上的屏幕上放置一个图像选择器对话框。它在模拟器上运行正常,但在设备上,选择器会暂时出现并消失。

任何想法如何解决?

1 个答案:

答案 0 :(得分:1)

UIImagePickerController* picker = [[UIImagePickerController alloc] init]; 
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
picker.delegate = self; 
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker];
self.popoverController = popover;          
popoverController.delegate = self;
[self.popoverController presentPopoverFromBarButtonItem:sender
                               permittedArrowDirections:UIPopoverArrowDirectionAny 
                                               animated:YES];
[picker release];