帮助UIPopOverController大小 [英] Help with UIPopOverController size

查看:121
本文介绍了帮助UIPopOverController大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在 UIScrollView 中有一堆按钮视图。当用户按下按钮时,我希望UIPopOverController显示指向所选按钮。它有点工作,但弹出窗口的大小错误,并指向视图中的随机点。这是我的代码。提前致谢。

So I have a view with a bunch of button in a UIScrollView. When the user presses a button, I want a UIPopOverController to display pointing at the selected button. It kind of works, but the popover is the wrong size and points to a random point in the view. Here is my code. Thanks in advance.

-(void)detail:(id)sender{
    UIButton *button = sender;
    NSLog(@"tag = %i", button.tag);

    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    self.popover = [[UIPopoverController alloc] initWithContentViewController:navController];
    self.popover.delegate = self;
    [self.popover presentPopoverFromRect:button.bounds inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}

比popover大小的问题:
在在弹出窗口内的视图,我有:

Than the problem with the size of the popover: In the view that is inside the popover, I have:

self.contentSizeForViewInPopover = scroll.contentSize;
NSLog(@"%f, %f", scroll.contentSize.height, scroll.contentSize.width);
NSLog(@"showing: %f, %f",  self.contentSizeForViewInPopover.height,  self.contentSizeForViewInPopover.width);

并且两个日志都匹配。所以我觉得一切都应该正常。但事实并非如此。这是一个截屏。如果您需要更多我的代码,请告诉我。在此先感谢。

and both logs are matching. So I think everything should work correctly. But it doesn't. Here is a screen shot. Let me know if you need more of my code. Thanks in advance.

推荐答案

关于弹出窗口的大小:我设法用变量加权的UILabel来做:

Regarding the size of the popover only: I managed to do it with a variable heighted UILabel:

UILabel *hinweis;
hinweis.text = @"...";
hinweis.frame = CGRectMake(x,y,width,800);
[hinweis sizeToFit];

对于箭头:您是否尝试过像self.parentViewController.view这样的不同的inView参数?

And for the arrow: have you tried a different inView param like self.parentViewController.view?

这篇关于帮助UIPopOverController大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆