【发布时间】:2013-02-20 14:16:10
【问题描述】:
我在导航控制器中有两个表视图控制器。 Cloth 表是主视图,当我单击其中一个单元格时,转到另一个提供详细信息的视图控制器,当我选择我想要的选项并返回导航按钮的返回时,我会丢失信息。如何将值带到主视图?
这是我的代码:主视图 - AddClothViewController
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([[list objectAtIndex:indexPath.row] isEqual:@"Categorias"] )
{
CategoriesViewController *DVC = [[CategoriesViewController alloc] initWithNibName:@"CategoriesViewController" bundle:nil];
[self.navigationController pushViewController:DVC animated:YES];
}
}
这是我的代码:类别 ViewController
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Set the checkmark accessory for the selected row.
[[tableView cellForRowAtIndexPath:indexPath] setAccessoryType:UITableViewCellAccessoryCheckmark];
// This is my main View Controller when i declare a variable category and I try to access from
//here
AddClothViewController *DVC = [[AddClothViewController alloc] initWithNibName:@"AddClothViewController" bundle:nil];
DVC.clothNew.categoria = [list objectAtIndex:indexPath.row ];
}
【问题讨论】:
-
您正在创建一个新的 AddClothViewController 实例,而不是回到原来的那个实例。
-
是的,你说得对!!。但是当我按下后退按钮时,我不知道如何获得价值。你有一个例子吗?非常感谢
标签: ios uinavigationcontroller uitableview