【问题标题】:UIPopoverController strange behaviorUIPopoverController 奇怪的行为
【发布时间】:2011-12-30 08:05:29
【问题描述】:

我正在使用 UIPopoverController 并使用 MPMediaPickerController 填充它以从 iPod 库中选择歌曲。我让它工作得很好。但是,我添加了一个完全不相关的功能(触摸按钮并将图像缩放到大尺寸),现在 UIPopoverController 仅在使用新功能后才会出现奇怪的行为。

使用按钮缩放功能后,UIPopoverController 以一种奇怪的方式出现。看起来它是从屏幕上的旋转状态开始动画并降落在正确的位置,但预期的行为是它应该出现在正确的位置。

// code for if the interface is a an iPhone, do not use popup     
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    [self presentModalViewController:picker animated:YES];

// 如果不是 iPhone 使用弹出媒体选择器的代码

else {
    UIPopoverController* pop = 
    [[UIPopoverController alloc] initWithContentViewController:picker];
    self.currentPop = pop;

// 检查 iPad 是纵向还是横向,并相应地显示弹出媒体选择器

    if (vertMode == TRUE) 
    {

//如果是纵向模式

       [pop presentPopoverFromRect:CGRectMake(668.0f, 846.0f, 10.0f, 10.0f) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:NO]; 

// 否则如果是横向模式

    }

    else if (vertMode == FALSE)

    {

       [pop presentPopoverFromRect:CGRectMake(900.0f, 580.0f, 10.0f, 10.0f) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:NO];


    }

  [pop release];

}

}

【问题讨论】:

  • 如果您从纵向开始,显示弹出框然后旋转到横向会发生什么?

标签: objective-c ios ipad uipopovercontroller


【解决方案1】:

好吧,我觉得回答我自己的问题有点傻,但我希望它可以在未来对其他人有所帮助。

我不完全确定为什么,但在我将图像缩放到大尺寸的按钮的功能中,我忘了添加:

 [UIView commitAnimations]; 

这样做的目的是完成缩放图像的动画运动,我猜是因为我从未提交过动画,它仍处于尝试为事物制作动画的某种状态。然后当我调用我的 popup 时,它会出现奇怪的动画。

所以我通过添加上面的一行来解决这个问题!

解决这个问题我感觉好多了!我希望它可以帮助其他人。

【讨论】:

  • 感谢您的大力帮助。
猜你喜欢
  • 1970-01-01
  • 2013-10-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-08
相关资源
最近更新 更多