0

我的应用程序是基于视图的应用程序。当我按下一个按钮时,我添加了一个 UITableView 类型的子类及其 .xib,我想加载 UITableView xib,但它只加载没有导航栏和搜索栏的表格。这是加载视图的代码:

- (IBAction)changeView:(id)sender;
{
   TableViewController *tableview =[[TableViewController alloc] initWithNibName:nil   bundle:nil];
   [self presentModalViewController:tableview animated:YES];
}

这是我要加载的内容:

图片 1 http://img571.imageshack.us/img571/3846/wantf.png

这就是它加载的内容:

图片 2 http://img528.imageshack.us/img528/9928/loadu.png

如何解决问题并使用导航和搜索栏加载视图?先谢谢各位小伙伴了。

4

2 回答 2

1

您需要将视图控制器包装在 UINavigationController 中,如下所示:

UINavigationController:最简单的例子

所以试试这个:

   TableViewController *tableview =[[TableViewController alloc] initWithNibName:nil   bundle:nil];
   UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:tableview]; 
   [self presentModalViewController:navController animated:YES];
于 2012-06-21T20:04:25.780 回答
0

在编辑您的 xib 文件时,我相信 XCode 为您提供了显示/隐藏搜索栏的选项。

于 2012-06-22T01:48:45.233 回答