在 ipad 或 iphone 中打开 UIImagePicker 使用波纹管代码:-
#define isiPhone (UI_USER_INTERFACE_IDIOM() == 0)?TRUE:FALSE
UIImagePickerController *pckrImage = [[UIImagePickerController alloc] init];
pckrImage.delegate = self;
if (isiPhone) {
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypePhotoLibrary])
{
pckrImage.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:pckrImage animated:YES];
}
else {
}
}
else
{
popover = [[UIPopoverController alloc]initWithContentViewController:pckrImage];
[popover presentPopoverFromRect:CGRectMake(450.0f, 825.0f, 10.0f, 10.0f) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
}
在选择 UIImaegPicker 时关闭:-
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
if(isiPhone)
{
[self dismissViewControllerAnimated:YES completion:^{
}];
}
else
{
[popover dismissPopoverAnimated:YES];
}
}