2011-03-26 63 views
1

我有一個UIViewController,它包含一個UIView子類作爲子視圖。在子視圖中,我動態創建另一個UIView。當最內層的視圖被創建時,UIViewController會通過一個委託通知它必須顯示一個UIPopovercontroller,它的箭頭必須指向最內層的視圖。在委託方法調用中,我還傳遞了最內層視圖的原點,以便UIViewcontroller使用此CGPoint創建popover控制器。問題是UIPopovercontroller沒有被放置在所需的位置。UIPopoverController inRect問題

MyController* myController = [ [ MyController alloc] init]; 
UINavigationController *aNavController = [[UINavigationController alloc]     initWithRootViewController: myController]; 
self.popOver = [[[UIPopoverController alloc] 
       initWithContentViewController:aNavController] autorelease]; 
[aNavController release]; 

CGRect rect; 
//CGPoint p = CGPointMake(currentPage.frame.size.width/2, currentPage.frame.size.height/2); 
rect.origin = point; //here point is the origin of the inner most view 
rect.size = self.view.frame.size; 
[self.popOver presentPopoverFromRect: rect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 

我在這段代碼中缺少的是迫使彈出顯示偏離位置而不是在所需的位置。

感謝

回答

0

我覺得你沒有傳遞正確看待你的酥料餅,檢查一次......

[self.popOver presentPopoverFromRect: rect inView:myInnerView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 
+0

我已經嘗試過,但仍然沒有運氣。 – Parvez 2011-03-28 05:49:25

+0

@Parvez:你是否第一次與彈出工作? – Jhaliya 2011-03-28 05:56:18

+0

@Parvez:請通過UIPopOvercontroller http://www.raywenderlich.com/1056/ipad-for-iphone-developers-101-uipopovercontroller-tutorial http://developer.apple.com/library/ios/#samplecode /MultipleDetailViews/Introduction/Intro.html#//apple_ref/doc/uid/DTS40009775嘗試瞭解他們如何在示例代碼中使用它... – Jhaliya 2011-03-28 06:04:05

0

rect你展示你的酥料餅從可能太大。

您將它設置爲整個視圖的大小,而不是最內部視圖的大小。