开发者

Add UITabBar Control!

I m stuck in a really simple problem. And i m afraid my question might annoy some people. The problem i am facing in short is that i want to add UITabBar Control to my iphone application other than the main screen.

Let me explain, I have done everything successfully Added UItabbar control from IB in the main window's xib, added a variable at the back end , associated it by dragging the line. Also added a UIWindow variable and wrote these lines .

[window addSubview:tabBarController.view];
[window makeKeyAndVisible];

when i launch the application a blank window appears and tab bar shows on its bottom. 开发者_开发技巧But the problem is dont want the tab bar to be displayed on my 1st screen ( or Main Screen whtever u call it). Its actually the 3rd ,4th screen of my app where i want the tab bar to be displayed on the bottom. Its so strange that TabBar control variable are added in the app delegate files of the application.Can anybody help ? Thanks!

Taimur


Unfortunately, the documentation for UITabBarController states the following:

When deploying a tab bar interface, you must install this view as the root of your window. Unlike other view controllers, a tab bar interface should never be installed as a child of another view controller.

While it's technically possible to add the UITabBarController's view as a subview of something other than the UIWindow, you'll find that it presents more challenges than you might expect. For example, since UITabBarController assumes that its view's parent is the full screen UIWindow, it will offset its frame by 20 pixels to accommodate the status bar.

So, my recommendation to you is to come up with a design in which your UITabBarController's view is a subview of the UIWindow if possible. This doesn't necessarily mean that it needs to be the first view that gets displayed. You can always add and remove subviews of your UIWindow in places other than applicationDidFinishLaunching:


on the window you want to add the tabbar controller to, use

[self.view addSubview:tabBarController.view]

instead of your two lines above

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜