You can try adding additional views that you add or remove as needed. In the window "File Owner", "First Responder", "View", etc. Add three UIView libraries from the library. You can change their names from “View” to “Verification”, “Download” and “Error”.
Now open each one of them and customize it as you like by adding buttons and tags and other similar things.
Return to Xcode, announce new views:
IBOutlet UIView *validView; IBOutlet UIView *loadView; IBOutlet UIView *errorView;
and be sure to create the appropriate connections in InterfaceBuilder. Any actions you want to associate with any of these views should work just fine.
Now, to switch, create an action (or three different ones). It can be an IBAction or not, as you like. In the title:
-(void)showError;
Now for implementation you may need something like this.
-(void)showError { // skip this if you always arrive from the validView if ([validView superview]) { [validView removeFromSuperview]; } [self.view addSubview:errorView]; }
You can get an animation lover if you want:
-(void)toggleErrorWithFlip { [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.8]; [UIView setAnimationTransition:([errorView superview] ? UIViewAnimationTransitionFlipFromLeft : UIViewAnimationTransitionFlipFromRight) forView:[self view] cache:YES]; if ([errorView superview]) { [errorView removeFromSuperview]; } else { [[self view] addSubview:errorView]; } [UIView commitAnimations]; }
The Repeat button can trigger an action on the lines of the following:
-(IBAction)retryLoad { [errorView removeFromSuperview]; [self.view addSubview:validView]; // do some stuff that retries whatever was tried and failed }
Again, this can happen with or without animation.
If there is a default view that you always return (for example, validatingView), then make it the original "View" and just add two other views on top of it (for example, loadView and errorView). This can save a little work depending on how you want everything to go.