我有一个 UIViewController 包含一个 UIView 子类作为子视图。在子视图中,我动态创建了另一个 UIView。当创建最内层视图时,UIViewController 通过委托通知它必须显示一个 UIPopovercontroller,其箭头需要指向最内层视图。在委托方法调用中,我还传递了最内层视图的原点,以便 UIViewcontroller 使用此 CGPoint 来创建弹出框控制器。问题是 UIPopovercontroller 没有定位在所需的位置。
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];
我在这段代码中缺少的内容是强制弹出框出现偏离位置而不是在所需位置。
谢谢