我正在使用UIImagePickerController
来挑选图片并在ipad应用程序中使用它在模拟器上工作正常但它在设备中没有打开imagepickerController
这里是我的代码
else if([labelType.text isEqualToString:@"Select Image"]){
selectedType=@"Select Image";
BOOL isiPhone;
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];
}
}
答案 0 :(得分:0)
请进行更改
UIImagePickerController *pckrImage = [[UIImagePickerController alloc] init];
pckrImage.delegate = self;
if (isiPhone) {
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypePhotoLibrary])
{
pckrImage.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:pckrImage animated:YES];
}
else {
}
}
else
{
UIPopoverController *popOver = [[UIPopoverController alloc]initWithContentViewController:pckrImage];
self.popoverImageViewController = popOver;
[self.popoverImageViewController presentPopoverFromRect:CGRectMake(450.0f, 825.0f, 10.0f, 10.0f) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
}
初始化对象
@property (strong,nonatomic) UIPopoverController *popoverImageViewController;
答案 1 :(得分:0)
试试这个:
UIImagePickerController *pckrImage = [[UIImagePickerController alloc] init];
pckrImage.delegate = self;
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypePhotoLibrary]) {
pckrImage.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
if (isiPhone) {
[self presentModalViewController:pckrImage animated:YES];
}
else
{
popOver = [[UIPopoverController alloc]initWithContentViewController:pckrImage];
[popOver presentPopoverFromRect:CGRectMake(450.0f, 825.0f, 10.0f, 10.0f) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
}
}
希望这有帮助。
答案 2 :(得分:0)
尝试使用UIPopoverArrowDirectionAny呈现popover。
[self.popoverController presentPopoverFromRect:CGRectMake(450.0f, 825.0f, 10.0f, 10.0f)
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];