Iphone 在iOS中导航到新视图

Iphone 在iOS中导航到新视图,iphone,ipad,uitableview,navigation,Iphone,Ipad,Uitableview,Navigation,在我的iPad应用程序中,我以编程方式添加了UISearchBar。 当我点击搜索栏时,会出现一个包含数据的表格。当我点击表中的行时,它应该导航到新视图 例如: 当我点击“reliance”时,它应该会显示一个新的视图。对我如何做到这一点有什么建议吗 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { ContentController

在我的iPad应用程序中,我以编程方式添加了
UISearchBar
。 当我点击搜索栏时,会出现一个包含数据的表格。当我点击表中的行时,它应该导航到新视图

例如:

当我点击“reliance”时,它应该会显示一个新的视图。对我如何做到这一点有什么建议吗

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath        {
     ContentController *detailview = [[ContentController alloc]            initWithNibName:@"ContentController" bundle:nil];    
      detailview.detailString = [NSString stringWithFormat:@"%d",indexPath.row];    

    [self.view addSubView:detailView];
     [detailview release];
   }

所以我在上面添加了代码。我还需要做什么吗?

执行
UITableViewDelegate
方法
didselectrowatinexpath
,并将新视图推送到导航堆栈上

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Some code 
// Initialize your new view here
[self.navigationController pushViewContoller:yourViewController animated:YES];
}
试试-


我需要在.xib中拖动任何东西吗?您不需要拖动任何东西,但如果需要,可以将tableview的委托拖动到文件所有者。只需确保您的类实现了
UITableViewDelegate
,然后在代码中添加这个
yourTableView.delegate=self我是否需要通过进入file->new file->cocoa Touch->UIViewControllerSubclass下添加viewController文件..我还需要写其他东西吗?这里的detailview是什么?单击reliance是我的新视图吗?我应该如何将我的旧视图映射到新视图?如果你想要新视图,那么你需要添加子视图而不是推viewController,我是否需要在cocoa Touch->UIViewControllerSubclass下添加viewController文件。它显示错误用UIMenuController替换ContentController
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath        {
     ContentController *detailview = [[ContentController alloc]            initWithNibName:@"ContentController" bundle:nil];    
      detailview.detailString = [NSString stringWithFormat:@"%d",indexPath.row];
   //  [self.navigationController pushViewController:detailview animated:YES];     

    [self.view addSubView:detailView];
     [detailview release];
   }