2012-03-26 103 views
4

我正在使用包含一些輸入字段的popover。由於iOS鍵盤覆蓋大屏幕區域,因此有時需要更正彈出窗口位置(通過移動其目標並在popover上調用-presentPopoverFromView:targetView)。我假設我無法精確確定彈出窗口的視圖矩形,但是具有箭頭方向和內容大小,我可以近似其當前位置。彈出箭頭方向無法確定

問題在於,即使彈出窗口清晰可見,我也會不斷得到未知的方向(UIPopoverArrowDirectionUnknown)。

在iOS 5.1 UIKit.framework中,頭文件UIPopoverController.h我們可以看到,我們可以得到popover arrow(上下左右是未知之一)的當前方向。唯一的條件是需要顯示popover

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

我們可以確定酥料餅呈現一個getter isPopoverVisible:但是

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

儘管我可以看到酥料餅的箭頭瞄準向上或向下等和myPopover.isPopoverVisible == YES,箭頭方向仍然是myPopover.popoverArrowDirection == UIPopoverArrowDirectionUnknown

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

EDIT(解決方案)

我的iOS 5.0.1我的設備(新iPad)上安裝:

popover被提出。編制目標是5.1。將設備更新至5.1後,問題完全消失。

+0

如果您已經解決了問題,請發佈答案並將其標記爲已接受,所以問題不會顯示爲未答覆。 – Greg 2012-10-05 12:09:37

+0

@PartiallyFinite,謝謝。學習... – Greg 2012-10-10 16:26:11

回答

0

我在我的設備(iPad)上安裝了iOS 5.0.1。編制目標是5.1。將設備更新至5.1後,問題完全消失。