UIPopoverController inRect 问题

发布于 2024-10-27 00:15:38 字数 1015 浏览 1 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

谢绝鈎搭 2024-11-03 00:15:38

我认为您没有将正确的视图传递给 popOver,请检查一次...

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

I think your are not passing the correct view to your popOver, check once ...

[self.popOver presentPopoverFromRect: rect inView:myInnerView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
仲春光 2024-11-03 00:15:38

您用来展示弹出框的矩形可能太大。

您将其设置为整个视图的大小,而不是最内部视图的大小。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文