到達可能性チェックを実行している最初の tableviewcontroller があります。これは 内で問題なく動作していますがviewDidLoad
、成功するまで接続を再試行する正しい方法を知りたいです。私の実装ファイルの関連コードは以下のとおり[self ViewDidLoad]
です。接続がダウンしている場合に挿入しようとしましたが、これはアプリをループに設定し (接続失敗NSLog
メッセージを返す) UIAlertView
、.
- (void)viewDidLoad
{
[super viewDidLoad];
if(![self connected])
{
// not connected
NSLog(@"The internet is down");
UIAlertView *connectionError = [[UIAlertView alloc] initWithTitle:@"Connection Error" message:@"There is no Internet Connection" delegate:self cancelButtonTitle:@"Retry" otherButtonTitles:nil, nil];
[connectionError show];
[self viewDidLoad];
} else
{
NSLog(@"Internet connection established");
UIButton *btn = [UIButton buttonWithType:UIButtonTypeInfoDark];
[btn addTarget:self action:@selector(infoButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
[self start];
}
}