I have finally gotten code for displaying an alert if there is no internet connection.
Reachability *r = [Reachability reachabilityWithHostName:@"m.google.com"];
NetworkStatus internetStatus = [r currentReachabilityStatus];
if(internetStatus == NotReachable){
NSLog(@"There's no connection");
UIAlertView *errorAlertView = [[UIAlertView alloc]
initWithTitle:@"No internet connection"
message:@"Internet connection is required to use this app"
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[errorAlertView show];
}else
NSLog(@"Internet connection is OK");
It doesn't work when a WebView is in a tabbed application. Is there anyway I could tweak the code to get it to be friendly with a WebView in a Tabbed View Controller?
I figured it out on my own. I created a UITabBarController file, and put the code into there, so every time I open the app, if there is no internet connection, I'll get the alert.