0
iPadのネットワーク状況を確認するために、数か月前にAppleのReachabilityを使用していました。それは前に働いた。今私はそれをテストしようとすると、私はいつもネットワークに到達できず、なぜか不思議に思っています。これについての考えは?ここに私のコードの一部です:iOS 5.1での到達可能性の問題?
// In the class I want to check for reachability to send email from, I access my singleton object WebServiceManager
WebServiceManager *wmgr = [WebServiceManager sharedInstance];
[wmgr CheckNetworkStatus];
if (wmgr.isInternetAvailable) {
if ([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc] init];
mailComposer.mailComposeDelegate = self;
[self presentModalViewController:mailComposer animated:YES];
}
else {
UIAlertView *mailNotConfiguredAlert = [[UIAlertView alloc] initWithTitle:@"This device is not configured to send mail" message:@"Please set up your mail account in order to send an email." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[mailNotConfiguredAlert show];
[mailNotConfiguredAlert release];
}
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Network Connection Unavailable" message:@"The network connection is currently unavailable. Please try again later." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil];
[alert show];
[alert release];
}
WebServiceManager
で
//
- (void)CheckNetworkStatus {
NetworkStatus internetStatus = [_networkReachable currentReachabilityStatus];
switch (internetStatus)
{
case NotReachable:
{
isInternetAvailable = NO;
break;
}
case ReachableViaWiFi:
{
isInternetAvailable = YES;
break;
}
case ReachableViaWWAN:
{
isInternetAvailable = YES;
break;
}
}
}