【问题标题】:Xcode:Reachability on additional view controller using storyboardXcode:使用情节提要的附加视图控制器上的可达性
【发布时间】:2013-08-17 11:49:32
【问题描述】:

我的应用有 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;

 }

【问题讨论】:

    标签: uiviewcontroller popup storyboard reachability


    【解决方案1】:

    对于任何有同样问题的人。我在 .M 文件中缺少这段代码。添加后,我的弹出警报效果很好。

    `
     -(void)viewDidLoad {
    
         {
    
             [super viewDidLoad];
             [self hasInternet];
    
         }
    

    `

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-08-12
      • 1970-01-01
      • 2013-10-21
      • 2012-07-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多