![](/img/trans.png)
[英]how to pass firstview value according to row selected of tableview in iphone
[英]iPhone SDK How to pass selected row from plist in tableview into a UIViewController
我有一個從plist填充的表格視圖,我想顯示所選行的詳細UIView。 我不知道如何將所選的行傳遞到詳細信息視圖控制器。 也許有人可以建議最好的方法。 該表由技術術語組成,當我選擇一行時,我想顯示其定義。 提前致謝。
一種解決方案是創建一個模型類,以表示要在表中顯示的元素。 第一個表將顯示每個模型對象的術語。 當用戶選擇一行時,您將創建詳細視圖控制器的實例(該實例將具有模型類型的成員)並設置模型成員。 然后推詳細視圖控制器。
簡而言之。 有一個可以對數據建模並在兩個表中都使用的類。
實現didSelectRowAtIndexPath
委托方法
(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DetailsViewController *detailsViewController = [[DetailsViewController alloc] initWithNibName:@"Details" bundle:nil];
detailsViewController.book = [books objectAtIndex:indexPath.row];
[self.navigationController pushViewController:detailsViewController animated:YES];
[detailsViewController release];
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.