在我的iPad应用程序中,我以编程方式添加了UISearchBar
。
当我单击searchBar时,会出现一个包含数据的表。当我点击表格中的行时,它应该导航到新视图
例如:
当我点击“依赖”时,它应该显示一个新视图。关于如何实现这一目标的任何建议?
- (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];
}
所以我添加了上面的代码。我还需要做其他事吗?
答案 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];
}