我正在工作的表视图中加载 4 个城市字符串,但是当我选择一个单元格并导航到另一个表时,它导航速度太慢。我在具有不同链接的另一个表中使用下面的相同代码。你能告诉我为什么需要很长时间(~4 - 6 秒)才能到达另一个视图吗?
- (void)viewDidLoad
{
[super viewDidLoad];
NSURL * url = [NSURL URLWithString:@"http://kalkatawi.com/jsonTest.php"];
NSData * data = [NSData dataWithContentsOfURL:url];
NSError *e = nil;
jsonArray = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&e];
jsonArray1 = [[NSMutableArray alloc] init];
for(int i=0;i<[jsonArray count];i++)
{
NSString * city = [[jsonArray objectAtIndex:i] objectForKey:@"city"];
[jsonArray1 addObject:city];
}
-
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
NSString *tempString = [jsonArray1 objectAtIndex:indexPath.row];
cell.textLabel.text = tempString;
return cell;
}
-
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
SeconfViewController *second = [[SeconfViewController alloc] initWithNibName:@"SeconfViewController" bundle:nil];
UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
NSString *cellText = selectedCell.textLabel.text;
NSString *edit = [NSString stringWithFormat:@"http://kalkatawi.com/jsonTest.php?d=1&il=%@", cellText];
second.str2 = edit;
[self.navigationController pushViewController:second animated:YES];
}