по ссылке на github есть пример как отследить что пропал инет
вот(я чуток изменил пример):
@interface MyViewController ()
@property (strong, nonatomic) SDReachability *reachability;
@end
@implementation MyViewController
//...
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self monitorReachability];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear];
[self stopMonitorReachability];
}
- (void)monitorReachability
{
self.reachability = [SDReachability reachabilityWithTarget:self action:@selector(reachabilityChanged:)];
}
- (void)stopMonitorReachability
{
self.reachability = nil;
}
- (void)reachabilityChanged:(SDReachability *)reachability
{
switch (reachability.reachabilityStatus)
{
case SDNotReachable:
{
NSLog(@"Connection lost");
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:nil message:@"Connection lost" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
// тут делаеш с view всё что захочешь
break;
}
case SDReachableViaWiFi:
NSLog(@"Connected via WiFi");
break;
case SDReachableViaWWAN:
NSLog(@"Connected via WWAN");
break;
}
}
@end
так делаешь для каждого ViewController-а или можешь сделать это один раз в RootViewController:
@interface MyRootViewController ()
@property (strong, nonatomic) SDReachability *reachability;
@end
@implementation MyRootViewController
//...
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self monitorReachability];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear];
[self stopMonitorReachability];
}
- (void)monitorReachability
{
self.reachability = [SDReachability reachabilityWithTarget:self action:@selector(reachabilityChanged:)];
}
- (void)stopMonitorReachability
{
self.reachability = nil;
}
- (void)reachabilityChanged:(SDReachability *)reachability
{
switch (reachability.reachabilityStatus)
{
case SDNotReachable:
{
NSLog(@"Connection lost");
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:nil message:@"Connection lost" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
[self.navigationController popToRootViewController]; // убираем все контроллеры из стека
// тут модифицируешь self.view - например добавляеш на неё label "Connection Lost"
break;
}
case SDReachableViaWiFi:
NSLog(@"Connected via WiFi");
break;
case SDReachableViaWWAN:
NSLog(@"Connected via WWAN");
break;
}
}
@end