gpt4 book ai didi

IOS Storyboard - 显示选择表格单元格的不同 View

转载 作者:可可西里 更新时间:2023-11-01 06:19:39 25 4
gpt4 key购买 nike

我是 ios 编程的新手。我有多个 View Controller 。我首先显示 tableView Controller,它之前有一个导航 Controller 。我想根据所选单元格显示特定的 View Controller。我已将 tableView Controller 设置为 dynamic原型(prototype) Cell 到 1我有从表连接到我的 View Controller 名称之一的 segue APP1ViewController 我还有另外两个 Controller 名称 APP2 和 APP3 .. 我如何连接它们以便在特定的单元格上加载特定的 View Controller 。这是显示单元格的代码.. 目前我的表格中有一个部分和三行

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

static NSString *CellIdentifier = @"AppCell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

switch (indexPath.row)
{
case 0:
cell.textLabel.text = @"APP 1 ";
cell.detailTextLabel.text = @"Detail of App 1...";
break;
case 1:
cell.textLabel.text = @"App2";
cell.detailTextLabel.text = @"Detail of App 2 app...";
break;
case 2:
cell.textLabel.text = @"App3";
cell.detailTextLabel.text =
@"Detail of App 3...";
break;

default:
cell.textLabel.text = @"Unkown";
cell.detailTextLabel.text = @"Unknown";
break;
}

return cell;
}

最佳答案

从具有表格的 Controller 而不是表格或单元格本身创建三个 segue。给每个 segue 一个唯一的标识符。在 tableView:didSelectRowAtIndexPath: 中,调用 TableView Controller 的 performSegueWithIdentifier:sender: 方法并选择与所选行匹配的标识符。

关于IOS Storyboard - 显示选择表格单元格的不同 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20921842/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com