Search code examples
iosios5uiviewuitoolbarcgrect

UIView frame changes when dismissing present view controller


I have a view that is modal presented. This view presents another modal view. When the view is dismissed the initial view (the first modal view) changes it's frame.. So a toolbar I have on this view slides up under the status bar... how can this be fixed?

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

The app does not use full-screen ...


Solution

  • this should be done because of deprecation of presentModalViewController AND dismissModalViewControllerAnimated. these two methods are deprecated in iOS6.

    Try this code. this will help you

    // ~~~~~~~~~~~~~~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];
    }
    

    Hope this will help you............