UIImagePickerController in UIPopoverController - location not working

谁说我不能喝 提交于 2019-12-20 04:53:45

问题


In an iPad app I'm writing I have button in a static table cell that launches an image picker inside a popover.

I want the popover's arrow to point at the button that launched the popover. Right now, when I tap the button it doesn't. It throws the popover on screen (with the working image picker) but the arrow either points to the top of the screen or kind of anywhere else (can't figure out if it's random or not--see below).

The tableview that holds the static cell that contains the button has its scroll disabled but is located on a scroll view. Could that cause random arrow locations?

Here is my code:

// present image picker in a popover
_imagePicker = [[UIImagePickerController alloc] init];
_imagePicker.delegate = self;
_imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
_imagePicker.allowsEditing = NO;
_imagePicker.navigationBar.tintColor = [UIColor redColor];
_imagePicker.navigationBar.backgroundColor = [UIColor greenColor];
_popover = [[UIPopoverController alloc] initWithContentViewController:_imagePicker];
[_popover presentPopoverFromRect:self.theButton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

Can someone please explain why the arrow isn't pointing at the button's frame and/or how to fix it?

Thanks.


回答1:


The button is likely not a direct subview of self.view.

Try:

[_popover presentPopoverFromRect:self.theButton.frame inView:self.theButton.superview permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];


来源:https://stackoverflow.com/questions/21652296/uiimagepickercontroller-in-uipopovercontroller-location-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!