On my initial view (Tab bar controller that loads a navigation controller) I check for internet connection. If the device has no active connection, I load a view that says Active Internet connection is required and has a retry button.
My problem is this: Since the initial view is navigation based, and by using the following code, I load the warning view, there is a back button to the initial view. So by pressing the back button, one can go back to the initial view, which is empty because it requires connection to display its content. So loading a view does not seem to be a solution in my case. Also by clicking the retry button, the user is sent back to initial view which again loads the alerter view. which goes into a crazy loop, with recurring navigation bars.
here is my redirect code:
- (void)viewDidLoad {
[super viewDidLoad];
if ([Connection isConnected]) {NSLog(@"connected");}
else {
Alerter *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"Alerter"];
[self.navigationController pushViewController:controller animated:NO];
}
Can anyone recommend a better way to handle this?