Question

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.

Était-ce utile?

La solution

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];
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top