简体   繁体   中英

removing previous UIView

i have three view controller with three different XIB, let's say ViewControllerA, ViewControllerB and ViewControllerC and every view controller has UIView variable named view in it's property. so it would be something like this :

@property (readwrite, retain) UIView *view;

first, scene ViewControllerA loaded, then after i touched a button scene of ViewControllerB appears. but i deliberately not removing UIView of ViewControllerA from super view. Then after i touched a button the scene navigate to ViewControllerC. here, before navigate to ViewControllerC i want remove UIView both of ViewControllerA and ViewControllerB from super view

removing UIView of ViewControllerB is not a problem, i can do something like this in ViewControllerB method :

[self.view removeFromSuperview];

but how can i remove UIView of ViewControllerA?

thanks

If you want totally independent of each other view controllers, you could switch them in appDelegate.window.rootViewController. Only create variable appDelegate that points to UIApplication.
And handle the animations by yourself.

Example:

AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
UIViewController *controller1 = [ViewControllerA alloc] initWithNibName:@"ViewControllerA" bundle:nil];
UIViewController *controller2 = [ViewControllerB alloc] initWithNibName:@"ViewControllerB" bundle:nil];

appDelegate.window.rootViewController = controller1;
appDelegate.window.rootViewController = controller2;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM