gpt4 book ai didi

ios - 使用 if 语句将 tableViewController 插入 navigationController

转载 作者:行者123 更新时间:2023-11-29 04:37:56 25 4
gpt4 key购买 nike

以下是我在 ProfilTableViewController.m 的 TableView 委托(delegate)中的 If 语句的摘录:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *currentCell =(UITableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
// Navigation logic may go here. Create and push another view controller.
if (currentCell.textLabel.text==@"phrase") {
MainViewController *phraseViewController =[[MainViewController alloc] initWithNibName:@"mesPhrase" bundle:nil];
[self.navigationController pushViewController:phraseViewController animated:YES];
}

在 Storyboard上,我创建了从 ProfilTVC 单元格到 MainViewController 的推送,并将 TableViewController 更改为“MainViewController”

当我运行应用程序时,单击 ProfilViewController 中的单元格不会执行任何操作:/什么鬼?

干杯,路易斯

最佳答案

currentCell.textLabel.text==@"phrase" 比较字符串的地址,而不是内容。查看 isEqualToString: 方法。

关于ios - 使用 if 语句将 tableViewController 插入 navigationController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10821126/

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