如何从表格到字符串获取单元格的文本

Poo*_*oja 1 iphone xcode objective-c title uitableview

我有2个视图,两个都是表视图第一个视图列表就在那里,所以当用户点击特定单元格时,我想获取所选单元格的文本并存储到变量中并推送第二个视图

例如stringVariable = cell.text

第二个视图

现在我想通过使用stringVariable变量来设置视图的标题

例如self.title = stringVariable;

我希望有人知道这个问题

先感谢您

Man*_*nni 7

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Save text of the selected cell:
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    stringVariable = cell.textLabel.text;

    // load next view and set title:
    MyView *nextView = [[MyView alloc] initWithNibName:@"MyView" bundle:nil];
    nextView.title = stringVariable;
    [self.navigationController pushViewController:nextView animated:YES];           

}
Run Code Online (Sandbox Code Playgroud)