Question

In Xcode 4 I was able to go to the root view where I used a ModalViewController using the following code:

[mHomeController dismissModalViewControllerAnimated: true];
[mHomeController.view addSubview:mHomeController->adView];

mHomeController is a global pointing to the first view controller.

When I upgraded to Xcode 5 I get a error in line:

[mHomeController dismissModalViewControllerAnimated: true]; [mHomeController.view addSubview:mHomeController->adView];

Saying method adView does not exist,

Now, none of my projects will build. Is there a way to fix this?

Was it helpful?

Solution

try

 [self dismissViewControllerAnimated:YES completion:^{

// try this and the additional code below
[[NSNotificationCenter defaultCenter] postNotificationName:@"POPTOROOTVIEW" object:nil];

//or just this line as it may be that you're popToRoot is called before the modal view is animated off

    [self.navigationController popToRootViewControllerAnimated:YES];
    }];

Then in another view controller have this

- (void)viewDidLoad
{
....
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(popToRootViewPlease) name:@"POPTOROOTVIEW" object:nil];
....
}

- (void)popToRootViewPlease
{
    [self.navigationController popToRootViewControllerAnimated:YES];
}

- (void) dealloc
{
    [[NSNotificationCenter defaultCenter]removeObserver:self];

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top