Apple から採用した Reachability クラスがあります。私の問題は、Apple に示されている ReachabilityAppDelegate ではなく、ListViewController に到達可能性検出を実装することです。私の問題:
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath と到達可能性検出で呼び出しメソッドをリンクしたい
セルが接続されていないことが検出された場合はセルを無効にし、接続されている場合はセルを有効にしようとしてい
ます
これは、viewDidLoad でコーディングされています。
[[NSNotificationCenter defaultCenter] addObserver: self selector:@selector(reachabilityChanged:) name:kReachabilityChangedNotification object: nil];
到達可能性は次のように変更されました。
-(void) reachabilityChanged: (NSNotification* )note{
Reachability* curReach = [note object];
NSParameterAssert([curReach isKindOfClass:[Reachability class]]);
[self updateInterfaceWithReachability: curReach];
}
UITableViewCells の無効化を実装するにはどうすればよいですか
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
上記の方法でこれをコーディングしたことに注意してください。
NSInteger row = [indexPath row]; NSString *contentForThisRow = nil; static NSString *MyIdentifier = @"MyIdentifier"; if (tableView == [[self searchDisplayController] searchResultsTableView]) { // Sort search results in alphabetical order NSArray *sorted = [searchResults sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)]; contentForThisRow = [sorted objectAtIndex:row]; }else { contentForThisRow = [nameArray objectAtIndex:row]; } UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier]autorelease]; } // Set Device names into Cells cell.textLabel.text = contentForThisRow; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; NSLog(@"Load cell done");
}