本文介绍了preferredContentSize不会缩小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用UIPopoverController弹出窗口.我使用preferredContentSize设置大小.然后,我使用Push更大尺寸的新视图控制器.当子视图弹出时,我想将窗口恢复到原始大小.但似乎行不通.

I use UIPopoverController to popover a window. I use preferredContentSize to set the size. Then, I use Push a new view controller with larger size. When the child view pop up, I like to recover the window to original size. But seems not work.

我已经把self.preferredContentSize = myWindowSize;但似乎无法恢复.

I already put the self.preferredContentSize = myWindowSize; But it seems can not recover.

在iOS6或更低版本中,我将contentSizeForViewInPopover设置为CGSizeZero,然后设置适当的大小.但是在iOS7上,它将使弹出窗口消失.

In iOS6 or before, I set the contentSizeForViewInPopover to CGSizeZero, then set the proper size. But on iOS7, it will make the popup disappear.

推荐答案

这为我解决了这个问题:

This solved it for me:

override func viewDidAppear(animated: Bool)
{
    navigationController?.preferredContentSize = preferredContentSize
    super.viewDidAppear(animated)
}

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

10-22 01:37