我的应用有 3 个视图控制器。VC#3(*Sponsor) 将用户带到我的网站,所以我正在尝试为这个 VC 实现可达性。我在项目中添加了系统配置框架和 Apples Reachability .H 和 .M 文件。禁用 ARC 以实现可达性 .M 文件和 VC#3 .M 文件。B&R 项目很好,但在断开互联网连接时我仍然没有收到弹出警报。我也将 Reachability.h 导入到 VC#3。我错过了什么?
VC#3(*赞助商).M
#import "Sponsor.h"
#import "ViewController.h"
@interface Sponsor ()
@end
@implementation Sponsor
-(void)viewDidLoad {
[webview loadRequest:[NSURLRequest requestWithURL:[NSURL
URLWithString:@"http://opticertificationprep.webs.com/"]]];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
-(IBAction)home:(id)sender{
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (BOOL) hasInternet {
Reachability *reach = [Reachability
reachabilityWithHostName:@"www.opticertificationprep.webs.com"];
NetworkStatus internetStats = [reach currentReachabilityStatus];
if (internetStats == NotReachable) {
UIAlertView *alertOne = [[UIAlertView alloc] initWithTitle:@"Error"
message:@"Check Your Internet Connection" delegate:self cancelButtonTitle:@"Okay"
otherButtonTitles:nil];
[alertOne show];
[alertOne release];
}
return YES;
}