Search code examples
iosios5uikituipopovercontroller

The popover arrow direction cannot be determined


I am using a popover that contains some input fields. Because the iOS keyboard covers large screen area, sometimes I need to correct the popups location (by moving its target and calling -presentPopoverFromView:targetView on the popover). I assume that I cannot determine the popup's view rectangle precisely but having the arrow direction and content size, I could approximate its current location.

The problem is that I am getting constantly unknown direction (UIPopoverArrowDirectionUnknown) even when the popup is clearly visible.

In iOS 5.1 UIKit.framework, header file UIPopoverController.h we can read that we can get the present direction of the popover arrow (one of up, down, left, right, unknown). The only condition is that the popover needs to be presented.

 /* Returns the direction the arrow is pointing on a presented popover. Before     presentation, this returns UIPopoverArrowDirectionUnknown.
  */
 @property (nonatomic, readonly) UIPopoverArrowDirection popoverArrowDirection;

We can determine if the popover is presented with a getter isPopoverVisible:

 /* Returns whether the popover is visible (presented) or not.
  */
 @property (nonatomic, readonly, getter=isPopoverVisible) BOOL popoverVisible;

But despite I can see the popover arrow aiming up or down etc. and the myPopover.isPopoverVisible == YES, the arrow direction is still myPopover.popoverArrowDirection == UIPopoverArrowDirectionUnknown.

The popover is presented by:

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

EDIT (solution)

I had iOS 5.0.1 installed on my device (iPad). The compilation target was 5.1. After updating the device to 5.1 the problem disappeared completely.


Solution

  • I had iOS 5.0.1 installed on my device (iPad). The compilation target was 5.1. After updating the device to 5.1 the problem disappeared completely.