UIPopoverController inRect 问题
我有一个 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];
我在这段代码中缺少的是强制弹出窗口显示偏离位置而不是在所需的位置。
谢谢
I have a UIViewController that contains a UIView subclass as a subview. In the subview, I dynamically create another UIView. When the innermost view is created then the UIViewController is informed via a delegation that it must show a UIPopovercontroller whose arrow head need to be pointing to the inner most view. In the delegate method call, I also pass the origin of the inner most view so that the UIViewcontroller make use of this CGPoint to create the popover controller. The problem is that the UIPopovercontroller is not being positioned at the desired location.
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];
What I am missing in this code that is forcing the popover to appear deviated from the position instead of at the desired place.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您没有将正确的视图传递给 popOver,请检查一次...
I think your are not passing the correct view to your popOver, check once ...
您用来展示弹出框的
矩形
可能太大。您将其设置为整个视图的大小,而不是最内部视图的大小。
The
rect
you are presenting your popover from may be too large.You have it set to the size of the entire view instead of the size of your inner most view.