设置 PopoverContentSize 时出现问题

发布于 2024-10-29 19:24:51 字数 1663 浏览 8 评论 0原文

我无法使用 size(650,400) 设置 contentsize。但即使我创建具有相同宽度和宽度的 popoverController正在创建的高度。

不知道什么是担忧? 点击 Enter 后,显示如下

在此处输入图像描述

- (IBAction)setButtonTapped:(id)sender
{
     popover *mpopover      =   [[popover alloc] init];

    UINavigationController  *NavController      =   [[UINavigationController alloc] initWithRootViewController:mpopover];

    //NavController.navigationBar.backgroundColor = [UIColor darkGrayColor];
    mPickerPopover  = [[[UIPopoverController alloc] initWithContentViewController:NavController] retain];

    CGSize popoversize      =   CGSizeMake(400, 90);

    [mpopover setparent:mPickerPopover];

    [mpopover setToolBarFrame:popoversize];

    mPickerPopover.popoverContentSize   = popoversize;

    [mPickerPopover presentPopoverFromRect:CGRectMake([sender frame].origin.x, [sender frame].origin.y, 20, 20) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];

    [mpopover release];
}

点击显示按钮时如下所示 在此处输入图像描述

 -(void)buttonView:(id)sender
 {

  CGSize popoversize        =   CGSizeMake(650, 320);

  [parent setPopoverContentSize:popoversize animated:YES];


  [toolbar setFrame:CGRectMake(0, popoversize.height- 90, popoversize.width, 60)];

  CATransition *transition = [CATransition animation];
  transition.type = kCATransitionPush;
  transition.duration = 1.0f;
  transition.timingFunction = UIViewAnimationCurveEaseInOut;
  [self.view.layer addAnimation:transition forKey:@"transitionViewAnimation"];
  }

I am not able to set the contentsize with size(650,400).But even i create popoverController with same width & height it is getting created.

No idea what is worry ?
On tapping Enter it shows as below

enter image description here

- (IBAction)setButtonTapped:(id)sender
{
     popover *mpopover      =   [[popover alloc] init];

    UINavigationController  *NavController      =   [[UINavigationController alloc] initWithRootViewController:mpopover];

    //NavController.navigationBar.backgroundColor = [UIColor darkGrayColor];
    mPickerPopover  = [[[UIPopoverController alloc] initWithContentViewController:NavController] retain];

    CGSize popoversize      =   CGSizeMake(400, 90);

    [mpopover setparent:mPickerPopover];

    [mpopover setToolBarFrame:popoversize];

    mPickerPopover.popoverContentSize   = popoversize;

    [mPickerPopover presentPopoverFromRect:CGRectMake([sender frame].origin.x, [sender frame].origin.y, 20, 20) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];

    [mpopover release];
}

On tapping show button looks like this
enter image description here

 -(void)buttonView:(id)sender
 {

  CGSize popoversize        =   CGSizeMake(650, 320);

  [parent setPopoverContentSize:popoversize animated:YES];


  [toolbar setFrame:CGRectMake(0, popoversize.height- 90, popoversize.width, 60)];

  CATransition *transition = [CATransition animation];
  transition.type = kCATransitionPush;
  transition.duration = 1.0f;
  transition.timingFunction = UIViewAnimationCurveEaseInOut;
  [self.view.layer addAnimation:transition forKey:@"transitionViewAnimation"];
  }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(5

樱娆 2024-11-05 19:24:51

目前还不清楚您要问什么,但对于弹出窗口,您需要确保在显示弹出窗口之前在内容视图控制器上设置 popoverContentSize 。通常我在视图控制器的 viewDidLoad 方法中执行此操作,该方法将在弹出窗口中使用。

It's not very clear what you are asking but with popovers you need to make sure you set the popoverContentSize on the content view controller before displaying the popover. Usually I do this in viewDidLoad method of my view controllers that will be used in popovers.

梦途 2024-11-05 19:24:51

Apple 文档中指出:

“您指定的宽度值必须至少为 320 点且不超过 600 点。”

也许尝试将宽度设置为 650 是问题所在。

From Apple's documentation:

"the width value you specify must be at least 320 points and no more than 600 points."

Maybe trying to set the width to 650 is the problem.

烂人 2024-11-05 19:24:51

我遇到了类似的问题,因为我无法在设备旋转期间更改弹出控制器的大小。我在 类似问题的答案中找到了导致解决方案的信息

因为我是通过 Bar 按钮呈现弹出窗口,所以 UIKit “尝试”通过在旋转期间调整弹出窗口的大小来提供帮助(因为在更改为不同的设备方向后,按钮的位置可能会有所不同)。尽管我确切地知道在每种情况下我希望弹出窗口的大小,但它并没有尊重我对 setPopoverContentSize 的调用。我的解决方案是关闭 willAnimateRotationToInterfaceOrientation 中的弹出框,然后在为 contentSizeForViewInPopover 和 popoverContentSize 设置适当的值后,在 didRotateFromInterfaceOrientation 中重新呈现相同的弹出框。 IHTH

I was having a similar problem in that I was unable to change the size of a popover controller during device rotation. I found the information that lead to my solution in a answer to a similar question.

Because I was presenting the popover from a Bar button, UIKit was "trying" to help by adjusting the size of the popover during rotation (because the position of the button might be different after a change to a different device orientation). Even though I knew exactly what size I wanted the popover to be in every case, it wasn't respecting my calls to setPopoverContentSize. My solution was to dismiss the popover in willAnimateRotationToInterfaceOrientation, then re-present the same popover in didRotateFromInterfaceOrientation after setting appropriate values for both contentSizeForViewInPopover and popoverContentSize. IHTH

骄兵必败 2024-11-05 19:24:51

考虑使用:

-(BOOL)splitViewController:(UISplitViewController *)svcontroller shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation 
{
    return NO;
}

这将以纵向和横向方向呈现弹出窗口。

Consider using:

-(BOOL)splitViewController:(UISplitViewController *)svcontroller shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation 
{
    return NO;
}

This will present the popover in portrait and landscape orientations.

淡淡绿茶香 2024-11-05 19:24:51

我注意到你有一个名为 popover 的 UIViewController ,它应该显示在 popoever 中
您引用为 mpopover
导航到该类并在 ViewController 循环的 ViewDidLoad 方法中
确保添加以下代码

self.contentSizeForViewInPopover = CGSizeMake(400, 90); // or Any size you like

...&...

I noticed you have a UIViewController called popover which should be shown inside the popoever
that you have referenced as mpopover
navigate to that class and in the ViewDidLoad Method of the ViewController cycle
make sure to add the following code

self.contentSizeForViewInPopover = CGSizeMake(400, 90); // or Any size you like

...&...

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