2013-02-20 138 views
-1

我在導航控制器中有兩個表格視圖控制器。布表是主視圖,當我點擊其中一個單元格時,轉到另一個視圖控制器,該視圖控制器給出了詳細信息,當我選擇我想要的選項並返回到導航按鈕返回時,我丟失了信息。我如何看待主視圖的價值?IOS - 從表格視圖控制器獲取值並將其發送到另一個表格視圖控制器

這裏我的代碼:主視圖 - 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]; 
} 

} 

這裏我的代碼:分類視圖控制器

- (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 ]; 

}

+0

您正在創建一個AddClothViewController的新實例,而不是回到你來自的那個。 – rdelmar 2013-02-20 16:09:47

+0

是的,你沒錯!但是當我按下後退按鈕時,我不知道該如何獲得價值。你有一個例子嗎?非常感謝 – user2049878 2013-02-21 10:01:27

回答

相關問題