我也考慮過多種選項,如:如何更改UIPopover的錨點? PresentFromRect對我無法正常工作。
* http://blog.waynehartman.com/archive/2012/01/07/uistoryboard-on-ios-5-the-good-the-bad-and-the.aspx * UIPopoverController Anchor Position * Can I change the UIPopover animation anchor point?
我試圖顯示在圖形頁面的地圖註釋的酥料餅。目前我正在使用一種解決方法。我在故事板視圖控制器中創建了一個視圖,並將我的popover錨定到該視圖。餘移動視圖到正確的位置,然後使用加載酥料餅:
(a)中找到的註釋的位置
CGPoint annotationPoint = [_mapView convertCoordinate:self.selectedAnnotationView.annotation.coordinate toPointToView:_mapView];
float boxDY= annotationPoint.y;
float boxDX= annotationPoint.x;
CGRect box = CGRectMake(boxDX,boxDY,1,1);
(b)中移動,我在故事板創建的視圖(anchorView)於註釋位置
anchorView.frame = box;
(c)示出酥料餅
[annotationPopoverController presentPopoverFromRect:box inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO];
中號我的直覺是,這種解決方法是不需要的。有沒有更簡單更優雅的方式來做到這一點?
感謝, 馬赫什
看看[這個答案](http://stackoverflow.com/questions/5582564/how-do-i-display-a-uipopoverview-as-a-annotation-to-the-map -view-ipad/5583505#5583505)有幫助。 – Anna
謝謝安娜。 我用塞格斯推出酥料餅 - 所以我不能正確定位酥料餅。
我相信我使用的解決方法適合定位彈出窗口,如果您使用的是segues。 說了這麼多,我現在使用你的答案建議的方法。 'self.detailsPopover = [[self storyboard] instantiateViewControllerWithIdentifier:@「identifierName」]; ' 乾杯, 馬赫什 – Mahesh