Question

I have 2 UIViews that are totally dependant on AppDelegate file.

First UIView is an Ad page that i have to launch when i start the app. But Already i have made the app with another HomeView that is dependant on AppDelegate.

I am adding AdView as follows in applicationDidFinishLaunching:

[self.view addSubView:AdView.view];

But now I want that when i click DONE button in AdView page I should be navigated to HomeView. But homeView should be a subView of appDelegate

How can i write a code on Done button that will remove AdView totally and bring Home View as a subView of appDelegate?? thanx in advance

Was it helpful?

Solution

in AdView , on button click event :

[self removeFromSuperView];

EDITED

As you want : remove AdView totally and bring Home View as a subView of appDelegate

I think you should create a method in delegate that removes your subview and add another subview to it. For that you need get reference of your delegate into the AdView and on button click call that delegate's method

- (void) methodInDelegate
{
   [AdView.view removeFromSuperView];
   [self performSelector:@selector(aMethodForAdding) withObject:nil afterDelay:0.1];
}

- (void) aMethodForAdding
 {
    [self.view addSubView:HomeView.view];
 }

OTHER TIPS

Use removeFromSuperView function of UIView.

- (void)removeFromSuperview ;

Use as below ...

[AdView removeFromSuperView];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top