OK so having a real headache with this one and most of the day has been wasted! with little progress!
The app:
- I have a tab bar application each tab has its own view controller and associated view.
- Say on tab 1 a user clicks on a button to go to a different view i have implemented the following:
[self.view addsubView:view 2]
- I keep adding views in this way
- If the user returns from that view to the previous view i get rid of it with a back button linked to
[self.view removefromsuperview]
Right! that all works fine... here comes the headache.
If the user completes the following: - navigates to view2 on tab 1 - switches to tab 2 - returns to tab 1 again
I would like to remove all subviews (loaded from viewControllers) so that they are presented with view1 on tab 1.
get it?
i have tried the following:
for(UIViewController *subview in [self.view subviews]) {
if([subview isKindOfClass:[View2Controller class]]) {
[subview.view removeFromSuperview];
} else {
// Do nothing
}
}
In an attempt to remove view2. (This method is called in view1's viewWillAppear
- and does get called but does not remove view2)
Any Ideas?? Any help with this issue would be highly appreciated
Cheers