Wrong screen size after dismissing UIImagePickerController

纵饮孤独 提交于 2019-12-05 08:14:21

Finally it's Fiexed

special thanks to danialzahid94.

for Fix this issue , you should call

[self dismissViewControllerAnimated:YES completion:^{
        self.view.frame = [[UIScreen mainScreen]bounds];
        [self.view layoutIfNeeded];
        self.tabBarController.view.frame  = [[UIScreen mainScreen]bounds];
        [self.tabBarController.view layoutIfNeeded]; // for fixing  tabbar Controller 

    }];

in 2 Delegate :

-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

If you are using auto layout, you could try self.view.layoutIfNeeded() when the UIImagePickerController dismisses. If that doesn't work, you can get the screen size and assign it to your self.view.frame like this:

self.view.frame = UIScreen.mainScreen().bounds

This usually works for me.

When I applied the @Mohamad Solution after updating the frame when I tapped on the textView its was showing blank black area above the keyboard and when I returned back from the controller Tabbar shifted down so I implemented the Below code is a permanent solution.

@property CGRect viewFrame;
@property CGRect tabbarFrame;

- (void)viewWillAppear:(BOOL)animated {
if (CGRectIsEmpty(self.viewFrame)) {
        self.viewFrame=self.view.frame;
        self.tabbarFrame=self.tabBarController.view.frame;
    }
}
- (void)viewDidAppear:(BOOL)animated {
 [self correctScreenSize];
}
-(void)correctScreenSize
{
    self.view.frame = self.viewFrame;
    [self.view layoutIfNeeded];
    self.tabBarController.view.frame  = self.tabbarFrame;
    [self.tabBarController.view layoutIfNeeded];

}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!