I currently don’t have any problems using:
-(IBAction)products:(id)sender {
products = [[Products alloc] initWithNibName:@"Products" bundle:nil];
[self.view addSubview:products.view];
}
I tied this action to buttons to change my views. I’m sure this isn’t correct though because the views are being stacked right? Will my application crash because of this? Know of any good sample code to switch views via IBAction?
If you are adding subviews that will cover the entire superview, you may consider removing an existing subview before adding a new one. You can do this by tagging views & then removing them.
While adding a view, assign it a tag-
To remove the older view, fetch it & remove it-
HTH,
Akshay