In my UIViewController class, i
-(void)switchToPuzzle2:(id)sender {
p2 = [Puzzle2 new]; // p2 is a UIView
[p1 addSubview:p2]; //p1 is UIView currently showing
[p1 removeFromSuperview];
[super viewDidLoad];
}
I would effectively like to put p2 on top of p1, or in place of p1.
This, however does (visibly) nothing.
Method is called
in the code that you have above, you are adding P2 to P1, then removing P1, thereby removing both from P1’s superView.
If you are trying to switch the two, add P2 to P1’s superview, then remove P1. i.e.
Also, do not call viewDidLoad. That will probably nullify everything that you are doing. Especially if you are loading from a Nib
Good luck