2012-06-21 164 views
0

我的应用程序是一个ViewBased应用程序。我添加了一个类型为UITableView的子类,它的.xib 当我按下一个按钮时,我想加载UITableView xib,但它只加载没有导航栏和搜索栏的表格。 下面就来加载视图代码:加载UITableView时看到的应用程序问题(.xib)

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

这是我要加载的内容:

image 1 http://img571.imageshack.us/img571/3846/wantf.png

,这就是它加载:

image 2 http://img528.imageshack.us/img528/9928/loadu.png

如何我可以通过导航栏和搜索栏来解决问题并加载视图吗? 在预先感谢队友。

+0

如果你有NIB文件,那你为什么不在初始化的时候传递NIB名字,但是你传递了零。传递你在[[TableViewController alloc] initWithNibName:@“TableViewController”bundle:nil]中创建的XIB文件的名称; – iNeal

回答

1

你需要一个UINavigationController来包装你的视图控制器,这样的:

UINavigationController: Simplest Example

那么试试这个:

TableViewController *tableview =[[TableViewController alloc] initWithNibName:nil bundle:nil]; 
    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:tableview]; 
    [self presentModalViewController:navController animated:YES]; 
+0

你能解释一下我到底需要做什么吗? 我去我的.xib并添加一个UINavigationController和? – Spale350z

+0

感谢队友......现在可以正常工作,但无法看到搜索栏:( – Spale350z

0

当编辑XIB文件,我相信的XCode给你显示/隐藏搜索栏的选项。

相关问题