presentViewController shows black sceen while UIModalTransitionStyleFlipHorizontal objective c

171 Views Asked by At

I'm facing issue with the UIModalTransitionStyleFlipHorizontal, Which gives black screen at background while transition and shows the actual screen.

enter image description here

After first time it shows the last view which added as rootview.

enter image description here

What actually I need to achieve is I don want to show the black and previous screen. It should show an empty screen background as like the below image.

enter image description here

The code I used to achieve the transition is

- (void)popViewController {
    UIViewController* rootController = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"MainViewController"];

    rootController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    UINavigationController *navigation = [[UINavigationController alloc]initWithRootViewController:rootController];

    [self.window.rootViewController presentViewController:navigation animated:YES completion:nil];
    [self.window makeKeyAndVisible];
}

I'm using storyboard with dynamic rootview.Anybody help me to fix it out. Thanks

2

There are 2 best solutions below

0
Rushang Prajapati On

Remove subview

Add this code on your method popViewController

AppDelegate *appDelegate =(AppDelegate *)[[UIApplication sharedApplication]delegate];
NSArray *subViewArray = [appDelegate.window subviews];
for (id obj in subViewArray)
          {
            [obj removeFromSuperview];
          }
0
iniyan On

I solved the issue by add window subview with background.

UIImageView* background = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.window.frame.size.width, self.window.frame.size.height)];
background.image = [UIImage imageNamed:@"TermsBg"];
[self.window addSubview:background];