TabBar 与导航栏/搜索栏和 TableView 结合

发布于 2024-08-16 02:47:02 字数 1009 浏览 3 评论 0原文

我在 iPhone 应用程序中使用了 TabBar 并以编程方式集成它。 我其中有几个 TabBarItems,每次单击都会加载带有相应 XYZ-View.xib 的 XYZ-ViewController。

现在我使用带有 TabBar 的屏幕和带有 SearchBar 的 NavBar 以及分段控件,就像 Apple 的示例一样: http://developer.apple.com/iphone/library/samplecode/ TableSearch/index.html

但在这个例子中,没有 TabBar 并将源代码复制到我的项目中会导致问题,我在 XViewController.m viewDidLoad 方法中进行了加载:

// Add create and configure the navigation controller.
MyAppDelegate *myAppDelegate = [[UIApplication sharedApplication] delegate];

// Add create and configure the navigation controller.
UINavigationController * navigationController = [[UINavigationControlleralloc] initWithRootViewController:self];
myAppDelegate.navController = navigationController;
[navigationController release];
[myAppDelegate.window addSubview:myAppDelegate.navController.view];

效果是,有一个标题正确的工具栏,但底部没有搜索栏和 TabBar。

谁能给我提示这里出了什么问题吗?

I used a TabBar in my iPhone application and integrated it programmatically.
I have several TabBarItems in it and every click will load a XYZ-ViewController with a corresponding XYZ-View.xib.

Now I use to have a screen with the TabBar and a NavBar with SearchBar and a segmented control like in this example of Apple:
http://developer.apple.com/iphone/library/samplecode/TableSearch/index.html

But in this example, there is not a TabBar and copy the source into my project causes the problem, that I did the loading in XViewController.m viewDidLoad method:

// Add create and configure the navigation controller.
MyAppDelegate *myAppDelegate = [[UIApplication sharedApplication] delegate];

// Add create and configure the navigation controller.
UINavigationController * navigationController = [[UINavigationControlleralloc] initWithRootViewController:self];
myAppDelegate.navController = navigationController;
[navigationController release];
[myAppDelegate.window addSubview:myAppDelegate.navController.view];

The effect is, that there is a toolbar with the correct title, but there is no searchbar and no TabBar at the bottom.

Could anyone give me a hint what's wrong here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怕倦 2024-08-23 02:47:02

我解决了这个问题:

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:test2ViewController];

NSArray* controllers = [NSArray arrayWithObjects:test1ViewController, navigationController, test3ViewController, nil];
[self.myTabBarController setViewControllers:controllers];

I solved the problem:

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:test2ViewController];

NSArray* controllers = [NSArray arrayWithObjects:test1ViewController, navigationController, test3ViewController, nil];
[self.myTabBarController setViewControllers:controllers];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文