我正在按表格视图单元格加载页面。我提出了一个if语句:
if ([webViewController webView].loading == YES) {
NSLog(@"Its loading!");
if (act == nil) {
NSLog(@"Its nil");
act = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
act.color = [UIColor blackColor];
} else {
act.hidden = NO;
}
act.center = self.view.center;
[act startAnimating];
} else {
[act stopAnimating];
[act setHidden: YES];
}
但是NSLog永远不会出现,所以永远不会被调用。但是当我将它部署到我的iPhone时,需要花费很长时间才能加载,但它仍然没有被调用。这里发生了什么?
更新 - 附加代码
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"TOUCHED CELL!");
// Push the web view controller onto the navigation stack - this implicitly
// creates the web view controller's view the first time through
[[self navigationController] pushViewController:webViewController animated:YES];
// Grab the selected item
RSSItem *entry = [[channel items] objectAtIndex:[indexPath row]];
// Construct a URL with the link string of the item
NSURL *url = [NSURL URLWithString:[entry link]];
// Construct a request object with that URL
NSURLRequest *req = [NSURLRequest requestWithURL:url];
// Load the request into the web view
[[webViewController webView] loadRequest:req];
if ([webViewController webView].loading == YES) {
NSLog(@"Its loading!");
if (act == nil) {
NSLog(@"Its nil");
act = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
act.color = [UIColor blackColor];
act.center = self.view.center;
[self.view addSubview:act];
} else {
act.hidden = NO;
}
act.center = self.view.center;
[act startAnimating];
} else {
[act stopAnimating];
[act setHidden: YES];
}
webViewController = nil;
webViewController = [[WebViewController alloc] init];
}