Question

In my app, I do a search asynchronously. When that completes my mapViewController with pins for the locations is displayed. 2 seconds after that, I do a modal transition over to a listViewController. I set the backgroundcolor like this:

self.view.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.65];

Making it possible to see the map behind it.

The problem is this: Less then a second after the listView appears you can see the map in the background for a second before it goes away. What I can see in the background now, is the mainViewController the app starts with.

it looks like this:

enter image description here

Less than a second later:

enter image description here

Any help/explanation would be greatly appreciated.

Was it helpful?

Solution

Your view is still transparent, but once your modal controller is at the top of the stack, the view behind it is hidden.

Try using :

yourController.modalPresentationStyle = UIModalPresentationCurrentContext;
[yourController present...];

OTHER TIPS

This code seems to work. I hope it will help. 

-(void)viewDidLoad
{
    [super viewDidLoad];

    // Do any additional setup after loading the view from its nib.

    MKMapView *mapView = [MKMapView new];
    [self.view addSubview:mapView];
    mapView.frame = self.view.bounds;

    UIGestureRecognizer *gestureRecognizer = [UITapGestureRecognizer new];
    [gestureRecognizer addTarget:self action:@selector(displayTransparentVC)];
    [self.view addGestureRecognizer:gestureRecognizer];
}

-(void)displayTransparentVC
{
    UIViewController *vc = [TransparentViewController new];
    self.modalPresentationStyle = UIModalPresentationCurrentContext;
    [self presentViewController:vc animated:YES completion:^{
    }];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top