我有一个 iPhone 应用程序(向日历添加提醒),其中通过以下代码显示首选项屏幕:
-(IBAction) showPreferences {
preferencesViewController.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentModalViewController:preferencesViewController animated:YES];
}
这将卷回“主”屏幕以显示preferencesViewController,如下所示:
主视图 Controller 和preferencesViewControllers都是通过XIB布局的。
问题在于,任何和所有输入元素(UISegmentedControls、UIButtons 等)在第一次呈现 View 时都会“动画化”——它们从左到右“增长”。 (您可以通过 installing the app - apologies for the plug 看到这一点)。随后返回此屏幕不会出现此问题。
如果我传入animated:NO,preferencesViewController就永远不会显示——为了让它出现,我还必须省略modalTransitionStyle,当我这样做时,从一个屏幕到另一个屏幕的转换是相当不和谐的。
这不是一个破坏交易的问题,但它已经困扰我一段时间了——有什么方法可以“强制”元素在我的 XIB 中的初始放置并防止它们被“动画化”,同时仍然通过精美的页面 curl 获得动画模态视图 Controller 的好处?
最佳答案
您需要在动画开始之前强制进行 View 布局。这可能是一个错误;归档那些雷达!
关于ios - PresentModalViewController 和 modalTransitionStyle 导致 XIB 中的所有控件变为 "animate in",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11388305/