IOS - 从表视图控制器获取值并将其发送到另一个表视图控制器

时间:2013-02-20 14:16:10

标签: ios uinavigationcontroller uitableview

我在导航控制器中有两个表视图控制器。 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];
}

}

这里是我的代码:Categories 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 ];   

}

1 个答案:

答案 0 :(得分:0)

我使用此tutorial解决了我的问题。 (ios开发的简单代表教程)