导航到iOS中的新视图

时间:2011-12-14 04:13:22

标签: iphone ipad uitableview navigation

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

例如:

this is my screenshot

当我点击“依赖”时,它应该显示一个新视图。关于如何实现这一目标的任何建议?

- (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];
   }

所以我添加了上面的代码。我还需要做其他事吗?

2 个答案:

答案 0 :(得分:0)

实施UITableViewDelegate方法didSelectRowAtIndexPath并将新视图推送到导航堆栈。

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

答案 1 :(得分:0)

尝试 -

- (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];
   }