我在 xcode 3 中很新,我真的需要帮助
我使用 UITableView 和 XML 开发了我的应用程序来显示内容。
我有 3 个 .xib 文件,它们分别是 rootViewController、SecondViewController 和 mainview。
所以问题是: 当我尝试在 rootViewController 中执行 didSelectrow 并访问 SecondViewController 中的 NSMutableArray *array 并在推送动画之前用 rootViewController 中的新数组值替换 *array 值时。
我的 SecondViewController 上的数组值第一次更改,但是当我按下后退按钮并选择另一行时,我的 SecondViewController 数组保持读取前一个数组而不是更改为新数组。我尝试初始化但没有运气
这是我在 rootViewController UITableview (didSelectRow) 上的代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if(2ndController == nil)
2ndController = [[DetailViewController alloc] initWithNibName:@"SecondViewController" bundle:[NSBundle mainBundle]];
//Declare xml NSMutable array record
ListRecord *record = [self.entries objectAtIndex:indexPath.row];
//access SecondViewController NSMutable *record
2ndController.record = [[[NSMutableArray alloc] init] autorelease];
//inserting the value from firstview to secondview before push
2ndController.record = record;
//push animation
[self.navigationController pushViewController:2ndController animated:YES];
}
这是我的第二个视图控制器:
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
switch(indexPath.section)
{
case 0:
[cell setText:record.name];
break;
case 1:
[cell setText:record.Age];
break;
case 2:
[cell setText:record.summary];
break;
}
return cell;
}
希望可以有人帮帮我..
提前致谢.....