设置UIPopOverController大小 [英] Set UIPopOverController size
问题描述
我有一个view
,在UIScrollView
中有一堆按钮.当用户按下按钮时,我希望UIPopOverController显示指向所选按钮的指针.确实可以,但是弹出窗口的大小不正确,并且指向视图中的随机点.这是我的代码.
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.
-(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];
}
比弹出窗口的大小问题多: 在弹出窗口内部的视图中,我有:
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屋!