我创建了一个应用程序,并有“图库”按钮,我想按下那个按钮我可以看到Ipad照片库中的所有图像。我的代码在这里:
- (IBAction)btGallery:(id)sender {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.delegate = self;
if(popoverController == nil)
{
popoverController = [[UIPopoverController alloc] initWithContentViewController:picker];
}
popoverController.delegate = self;
[popoverController presentPopoverFromRect:self.view.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
但是当我按下按钮时,我什么都看不见......请帮助我!
答案 0 :(得分:2)
我已经以编程方式完成了它并且它为我工作。 在按钮方法中添加此代码
确保更改ivars的名称
self.picker = [[UIImagePickerController alloc] init];
self.picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
self.picker.delegate = self;
self.popOver = [[UIPopoverController alloc] initWithContentViewController:self.picker];
[self.popOver presentPopoverFromRect:CGRectMake(10, 30, 200, 350)
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionUp
animated:YES];}
这应该对你有用,如果不能,请通知。