2011-03-23 125 views
5

我想將UIPopoverArrowDirection向左移動,使得實際的箭頭不再居中,但從左側多了25%,右側多了75%。UIPopoverController更改UIPopoverArrowDirection的位置

爲了幫助理解我的意思看到兩個屏幕截圖我希望它像第二個...

Normal Popover

The Popover with correctly placed arrow that I want

的問題是,有沒有真正的方法深入popover班...除非有人制作了我可以使用的第三方軟件?

無論如何,如果有人知道如何解決這個問題似乎是一個很重要的問題...請讓我知道...

〜戴夫

回答

7

通過指定「presentPopoverFromRect」並使該矩形足夠受限,這已經可以通過內建類來實現。

example doing this

的下面取出直出導致上述代碼的代碼。額外的絨毛是因爲小U齒輪的東西在UINavigationBar中的UIToolbar中。 r是UIToolbar的框架,它正在調整爲正確的位置(箭頭)或稍微偏離中心位置。 MGSettingsView是視圖控制器(具有「啓用轉換」,「啓用夜間模式」等)。

UINavigationItem *item = scrollView.navbar.topItem; 
UIToolbar *authorTools = (UIToolbar *)[item.rightBarButtonItem customView]; 
CGRect r = authorTools.frame; 
r.size.width = 18; 
r.origin.x += 12; 

CGSize popoverSize = CGSizeMake(300.f, 500.f); 
MGSettingsView *settingsView = [[MGSettingsView alloc] initWithSize:popoverSize]; 
UIPopoverController *poctl = [[UIPopoverController alloc] initWithContentViewController:settingsView]; 
settingsView.popover = poctl; 
poctl.delegate = self; 
poctl.popoverContentSize = popoverSize; 
[poctl presentPopoverFromRect:r inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 
[settingsView release]; 

如果這不是你問什麼,你最好改一下你的問題,我認爲。 :)

0

檢查下面的方法在此您可以爲矩形爲arrowDirections方向。

- (void)presentPopoverFromRect:(CGRect)rect inView:(UIView *)view permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections animated:(BOOL)animated 
+0

@David van Dugteren:讓我知道你是否仍然面臨任何問題... – Jhaliya 2011-03-24 19:28:57

1

UIPopoverController類提供了一種從座標(Rect)顯示內容的簡單方法。您可以設置想要自動化的popoverArrowDirection,就是這樣。從這些信息中,系統將自動顯示彈出窗口以適應屏幕並尊重您想要的直接,您無法要求更多。