Ios 从UITableView中选择行时显示新UIview

Ios 从UITableView中选择行时显示新UIview,ios,objective-c,uitableview,uiview,Ios,Objective C,Uitableview,Uiview,我有一个UITableView,它有3行。第一行在按下时呼叫一个电话号码,这样就可以正常工作 我还有另外两个UIViewController,我希望在UITableView中选择相应行时显示它们 下面是我的didSelectRow方法 -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { //deselect row [tableView dese

我有一个UITableView,它有3行。第一行在按下时呼叫一个电话号码,这样就可以正常工作

我还有另外两个UIViewController,我希望在UITableView中选择相应行时显示它们

下面是我的didSelectRow方法

-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    //deselect row
    [tableView deselectRowAtIndexPath:indexPath animated:YES];



    switch (indexPath.row)
    {
        case 0:
             [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:1800333000"]];
            break;
        case 1:

            break;
        case 2:

            break;

        default:
            break;
    }
}
可以看出,我已经设置了开关表达式。我想知道如何调用另外两个UIView


有人能提供显示这些视图所需的代码吗?

您的问题不太清楚您到底在做什么,但我认为您需要的是从UITableViewCell创建一个segue,特别是一个segue

要做的第一件事是控制单击并将连接从UITableView单元格拖动到情节提要中的另一个视图。这将在“表格视图”单元和下一个视图之间创建一条带小圆的直线。单击该圆可在“特性检查器”中设置和编辑分段特性。然后在UITableViewController类中,您需要有一个prepare for segue方法。下面是我编写的一些示例代码,其中有一个额外的if语句,因为我实际上有两个uitableView—一个来自UITableViewController,另一个来自searchbarviewcontroller(位于UITableViewController内)


另一件事是,您还需要研究什么是nsindepath。通常,您在该结构中使用的属性是.row属性。

您对“UIViewControllers which you like to display”(您希望显示的UIViewControllers)是什么意思?他们是应该在UITableView中创建新的单元格,还是应该以全新的ViewController方式打开?很抱歉,我想根据选择的行访问故事板中的2个UIView。通常情况下,我只会在故事板中使用segue,但我不能在UITableview中使用segue。你可以使用segue来实现这一点——你只需要直接从控制器(而不是单元格)连接它们,然后根据选择的行来决定调用哪一个。我不知道这是可能的-非常感谢!但是,不管选择了哪一行,这不是只链接到一个UIView吗?不,您可以链接到多个视图,这取决于segue标识符是什么(这是您设置的变量)。因此,根据选择的行,您可以选择适当的序列。
// In a story board-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
    if ([sender isKindOfClass:[UITableViewCell class]]) {


    NSIndexPath * SBidxPath = [self.searchDisplayController.searchResultsTableView indexPathForCell:sender];

    NSIndexPath * TBidxPath = [self.tableView indexPathForCell:sender];
    NSIndexPath * idxPath = [[NSIndexPath alloc] init];
    if (!SBidxPath) {
        idxPath = TBidxPath;
    }
    else{
        idxPath = SBidxPath;
    }


        if ([segue.identifier isEqualToString:CELL_PUSH_SEGUE_ID]) {
            if ([segue.destinationViewController isKindOfClass:[YTViewController class]]) {
                [self prepareYTViewController:segue.destinationViewController withDictionaryEntry:[self.dictionaryEntries objectAtIndex:idxPath.row]];
            }
        }
    }

}