Search code examples
iphoneiosobjective-cuiviewcontrollerstatusbar

presentViewController is moving my rootViewController


I would like to know if anyone have an idea about a problem I have !

I have a simple viewController, with a custom appDelegate.window.frame (0, 20, width, height), with its own navigationController. I implemented a UIButton, that present an empty view controller.

UIViewController *v = [_controllersList objectAtIndex:indexPath.row];
        v.modalPresentationStyle = UIModalPresentationCurrentContext;
        [self presentViewController:v animated:YES completion:nil]; 

By now, everything is working. If I present that new controller (everything is fine with it!). When I dismiss the new view, my original view controller frame has changed graphically but not programmatically!

(The result is that my window is stuck to the top of the view, and cropped, with 20 blacks pixel to the bottom).


Solution

  • This solution will resolve your problem,when ever you Dismiss a view then view will appear will call every time.

    -(void)viewWillAppear:(BOOL)animated {  
    
      self.view.frame = [[UIApplication sharedApplication].keyWindow bounds];
    }