我目前正在创建一个带有 tableview 的应用程序,现在我喜欢发生的是,当我单击第一行时,它将显示 view1,当我单击第二行时,它将显示 view2。我怎样才能做到这一点?
我尝试使用 if else 语句 id my didSelectRowAtIndexPath
但它在这里不起作用是我的一段代码
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
int EntryIndex = [indexPath indexAtPosition:[indexPath length]-1];
{
AboutViewController *aboutView = [[AboutViewController alloc]init];
aboutView.getId4 = [[contentArray objectAtIndex:EntryIndex]objectForKey:@"title"];
aboutView.aboutofficeId = getId3;
[self.navigationController pushViewController:aboutView animated:YES];
}
else
{
DepartmentsViewController *deptView = [[DepartmentsViewController alloc]init];
deptView.getId5 = [[contentArray objectAtIndex:EntryIndex]objectForKey:@"title"];
deptView.deptoffice = getId3;
[self.navigationController pushViewController:deptView animated:YES];
}
}