iphone - Tableview推送到不同的 View

标签 iphone ios xcode

我有这段代码,当按下单元格时,它会推送到新 View 。这个新 View 根据按下的单元格的名称更改其标题。但是,所有单元格的 View 都是相同的,如果我更改一个单元格下的某些内容,它会更改每个其他单元格的 View 。我怎样才能做到这一点,以便每个单元格的每个 View 都不同,而不创建大量 View ;这是不切实际的。谢谢。

推送代码:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];

ACollection *newView = [[ACollection alloc] init];
newView.template = [[Global collections] objectAtIndex:indexPath.row];

newView.theTitle = [self.tableView cellForRowAtIndexPath:indexPath].textLabel.text;
[self.navigationController pushViewController:newView animated:YES];
}

最佳答案

theTitle 似乎是您在单元格选择时设置的局部变量。 但是,导航 Controller 在导航项中设置 View Controller 的标题。 因此,您可以像这样设置 AVCollections 标题:

newView.navigationItem.title = [self.tableView cellForRowAtIndexPath:indexPath].textLabel.text;

在细胞选择期间。

关于iphone - Tableview推送到不同的 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13561706/

相关文章:

iphone - 我可以使用 Bonjour 连接两台 iOS 设备,一台使用 3G 网络,一台使用 WiFi

iphone - iOS 7 模态显示在状态栏下方

iphone - 无法通过反汇编解码简单的 ARM 函数原型(prototype)?

ios - 如何快速更新高分

ios - 静态库的 Xcode 7 存档错误

iphone - 谁能指出我可以遵循的指示以学习如何在Xcode中处理音频

iphone - 如何为 NSString drawAtPoint 设置上下文?

ios - 我应该从 iOS 上的 Realm 中删除旧表吗?

ios - 自动续订,如何获取用户(客户端)邮箱地址和 zip ?

iOS: AppStore 输入版本错误,如何解决?