这是ProfilTableViewController.m的表视图委托中的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];
}


在情节提要上,我创建了一个从ProfilTVC单元到MainViewController的推送,并将TableViewController更改为“ MainViewController”

当我运行该应用程序时,单击ProfilViewController上的某个单元不会执行任何操作:/
wtf?

干杯,
路易

最佳答案

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

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

10-10 17:36