开发者

Adding Tab Bar Controller to Root View of UISplitViewController?

How would I set a UITabBarController w开发者_开发技巧ith all its individual view controllers as the root view in a split view? IB doesn't seem to let me change the class of the root view controller to anything else…I'm using Xcode 4.


Are you using the split-view based application-option? In that case, it worked for me to just extend : UITabBarController in the RootViewController.h-file. I'm not sure what behaviour you want here, but if you set it up like that, you should get the tabbar with all your views (you have to add them in RootViewController.m ofc) in the "root"-option on the navigation bar.

If you want the DetailView to show the same, you have to add a navigationcontroller to the detailview as well.

As for the "more elegant" solution with IB, I'm afraid I'm not very fond of or very experienced with IB.


You want to add tabbarcontroller to your split view at rootview side and its very simple. create as many viewcontrollers subclasses with xib for ipad as u want to put in tabbarcontroller.

  • Then expand your splitview , u have two things navigationcontroller(which in turns contain rootview controller),detailview controller(right side view).
  • Open your library just drag tabbar controller exectly onto navigationcontroller ,so it will replace all that navigation controller and rootviewcontroller(i assume u dont need that rootview controller or u can create it later).
  • now expand this tabbar controller u can see viewcontroller 1 - viewcontroller 2 etc.
  • Now simply select view controller 1 , open attributes and select nib file on [command 1 attribute] and select controller file for that nib file by press[command 4 attribute].
  • Reapet this for view controller 2 in tabbarcontroller and save close IB. run program select landscape then u can see its done.


Thanks to dh14-sl and lecou—the solution was a combination of both your answers. I was trying to drag a tab bar controller from the library onto the list of elements but it wasn't working—turns out I had to drag it to the view itself. Then I had to change the parent class of my rootvc and re-setup connections, but now it seems to work! Thanks guys!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜