В моем коде у меня был UIImageView, всякий раз, когда я нажимал на него, в PopOverController открывался PickerView с изображениями из библиотеки iPhone.
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
[myImageView addGestureRecognizer:singleTap]; // added action for SingleTap
- (void)handleSingleTap:(UIGestureRecognizer *)gestureRecognizer {
// single tap does nothing for now
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypePhotoLibrary])
{
UIImagePickerController *imagePickerController =
[[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
imagePickerController.sourceType =
UIImagePickerControllerSourceTypePhotoLibrary;
UIPopoverController *popVC = [[UIPopoverController alloc]
initWithContentViewController: imagePickerController];
popVC.delegate = self;
[popVC setPopoverContentSize:CGSizeMake(500, 500)];
UIView *tempView = gestureRecognizer.view;
CGPoint point = CGPointMake(tempView.frame.size.width/2,
tempView.frame.size.height/2);
CGSize size = CGSizeMake(100, 100);
[popVC presentPopoverFromRect:
CGRectMake(point.x, point.y, size.width, size.height)
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
}
else
{
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Error accessing photo library"
message:@"Device does not support a photo library"
delegate:nil cancelButtonTitle:@"Cancel"
otherButtonTitles:nil];
[alert show];
[alert release];
}
}
Счастливое кодирование.