【问题标题】:Use dictionary with didSelectRowAtIndexPath将字典与 didSelectRowAtIndexPath 一起使用
【发布时间】:2010-08-08 17:42:32
【问题描述】:

我正在尝试从所选单元格中获取跟踪名称并将其传递给 didSelectRowAtIndexPath 中的下一个视图。我该怎么办? http://pastebin.com/bgXNfjie

【问题讨论】:

    标签: iphone objective-c uitableview didselectrowatindexpath


    【解决方案1】:

    如果我理解正确,那么这不是什么大事。您只需在 TrailViewController 中创建一个属性来保存您的值并像这样分配它:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
            TrailViewController *trailViewController = [[TrailViewController alloc] initWithNibName:@"TrailViewController" bundle:[NSBundle mainBundle]];
            NSDictionary *dict = [rows objectAtIndex: indexPath.row];
            trailViewController.trailName = [dict objectForKey:@"name"];
            [self.navigationController pushViewController:trailViewController animated:YES];
            [trailViewController release];
    }
    

    您可能希望将完整的 NSDictionary 分配给 TrailViewController 的属性,而不仅仅是名称,但这取决于您。希望能帮上忙……

    【讨论】:

      猜你喜欢
      • 2015-05-10
      • 2014-11-14
      • 2012-09-02
      • 1970-01-01
      • 1970-01-01
      • 2012-05-20
      • 2014-12-23
      • 1970-01-01
      • 2016-10-26
      相关资源
      最近更新 更多