【问题标题】:IOS - get a value from a table view controller and send it to another table view controllerIOS - 从表视图控制器获取值并将其发送到另一个表视图控制器
【发布时间】: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


【解决方案1】:

我通过使用这个tutorial 解决了我的问题。 (简单的ios开发委托教程)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-11
    • 1970-01-01
    • 2020-10-10
    • 1970-01-01
    相关资源
    最近更新 更多