ios - PresentModalViewController 和 modalTransitionStyle 导致 XIB 中的所有控件变为 "animate in"

标签 ios uiviewcontroller uikit

我有一个 iPhone 应用程序(向日历添加提醒),其中通过以下代码显示首选项屏幕:

-(IBAction) showPreferences {   
    preferencesViewController.modalTransitionStyle = UIModalTransitionStylePartialCurl;
    [self presentModalViewController:preferencesViewController animated:YES];
}

这将卷回“主”屏幕以显示preferencesViewController,如下所示:

this screenshot

主视图 Controller 和preferencesViewControllers都是通过XIB布局的。

问题在于,任何和所有输入元素(UISegmentedControls、UIButtons 等)在第一次呈现 View 时都会“动画化”——它们从左到右“增长”。 (您可以通过 installing the app - apologies for the plug 看到这一点)。随后返回此屏幕不会出现此问题。

如果我传入animated:NO,preferencesViewController就永远不会显示——为了让它出现,我还必须省略modalTransitionStyle,当我这样做时,从一个屏幕到另一个屏幕的转换是相当不和谐的。

这不是一个破坏交易的问题,但它已经困扰我一段时间了——有什么方法可以“强制”元素在我的 XIB 中的初始放置并防止它们被“动画化”,同时仍然通过精美的页面 curl 获得动画模态视图 Controller 的好处?

最佳答案

Already answered here .

您需要在动画开始之前强制进行 View 布局。这可能是一个错误;归档那些雷达!

关于ios - PresentModalViewController 和 modalTransitionStyle 导致 XIB 中的所有控件变为 "animate in",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11388305/

相关文章:

ios - UINavigationBar 详细信息文本标签

objective-c - 在 uikeyboard 顶部添加工具栏

python - Swift,如何从 Pandas JSON 文件导入 JSON 文件

ios - 是否可以在 statusBarOrientation 更改时添加观察者或通知?

ios - statusBarStyle 没有改变?

iphone - UIViewController:将 self.view 设置为我的 View 或将我的 View 添加为 subview ?

swift - 以编程方式在 didSelectRowAt 上从一个 ViewController 导航到另一个

iphone - 扩展 UITextView

ios - 将 "Clear"按钮添加到 iPhone UITextField

ios - 如何让按钮打开/关闭 UITableViewController 的一部分?