【问题标题】:UIView frame changes when dismissing present view controller关闭当前视图控制器时 UIView 框架发生变化
【发布时间】:2012-12-11 12:59:57
【问题描述】:

我有一个模态视图。此视图呈现另一种模式视图。当视图被关闭时,初始视图(第一个模态视图)会改变它的框架。所以我在这个视图上的工具栏会在状态栏下向上滑动... 如何解决这个问题?

2012-12-11 14:53:49.976 app[11225:907] toolbar frame: {{0, 0}, {320, 44}}
2012-12-11 14:53:49.979 app[11225:907] view frame: {{0, 20}, {320, 460}}
2012-12-11 14:54:07.496 app[11225:907] toolbar frame: {{0, 0}, {320, 44}}// here the second modal view is dismissed 
2012-12-11 14:54:07.498 app[11225:907] view frame: {{0, 0}, {320, 480}}

该应用程序不使用全屏...

【问题讨论】:

  • 我将此问题标记为重复。你昨天在这里问了这个问题:stackoverflow.com/questions/13788847/… 请不要在同一个问题上发布多个问题。编辑您的第一个问题并将您在此处提供的信息放在另一个问题中。

标签: ios ios5 uiview uitoolbar cgrect


【解决方案1】:

应该这样做是因为 presentModalViewControllerdismissModalViewControllerAnimated 已弃用。这两种方法在 iOS6 中已弃用。

试试这个代码。这对你有帮助

// ~~~~~~~~~~~~~~present

if ([self respondsToSelector:@selector(presentViewController:animated:completion:)])
{
    [self presentViewController:test animated:YES completion:nil];
}
else
{
     [self presentModalViewController:test animated:YES];
}
// ~~~~~~~~~~~~~~dismiss

if ([self respondsToSelector:@selector(dismissViewControllerAnimated:completion:)])
{
    [self dismissViewControllerAnimated:animated completion:nil];
}
else
{
    [self dismissModalViewControllerAnimated:animated];
}

希望对你有帮助............

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-10-03
    • 2019-05-30
    • 1970-01-01
    • 2017-07-09
    • 2016-11-27
    • 2013-07-23
    • 1970-01-01
    相关资源
    最近更新 更多