当解除当前视图控制器时,UIView帧会发生变化

时间:2012-12-11 12:59:57

标签: ios ios5 uiview uitoolbar cgrect

我有一个模态呈现的视图。该视图提供了另一种模态视图。当视图被取消时,初始视图(第一个模态视图)改变了它的框架。因此,我在此视图上的工具栏在状态栏下滑动... 怎么能解决这个问题?

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}}

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

1 个答案:

答案 0 :(得分:0)

这应该是因为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];
}

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