我用隨機數據填充我的tableView。所以我不知道我有多少行,以及如何將它重定向到我想要的屏幕。我填寫:TableView:didSelectRowAtIndexPath,如何捕獲行名
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MyClass *currentScreenElement = [self.tableRows objectAtIndex:indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:currentScreenElement.objectName];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:currentScreenElement.objectName];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
cell.textLabel.text = currentScreenElement.objectName;
return cell;
}
而且這工作正常。我有一個填充行的tableView。現在我想重定向到新的屏幕和我一起做:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NewScreenClass *myScreen = [[NewScreenClass alloc] init];
self.detailViewController = [[CreateView alloc] initWithScreenDef:[myScreen returnScreenFromName:@"second"]];
[self.navigationController pushViewController:self.detailViewController animated:YES];
}
我當然知道,我actualy在這裏做的是建立在同一個屏幕的每一行。但是,我怎麼能重定向到我想要的屏幕? 我的currentScreenElement
對象包含屬性:objectName
(tableView中的顯示名稱)和objectTarget
(屏幕定義)。兩個NSString。
而我的問題是我應該保存我的currentScreenElement以某種方式行修補程序或者我應該從dislay名稱捕獲objectName?