3

my iPad app starts with a normal UIView showing a login. After the user logged in the screen is supposed to switch to a split view. XCode's SplitViewTemplate (and all examples on the web I found) however, place UISplitViewController in the main window's xib and define an outlet in the app delegate. I find that unlogical in my case because I don't need the controller at startup and would like to (following Apple's guidelines) place the split view controller in its own XIB. Has anybody a working example or a small step by step instruction? I always end up with the XIB not being loaded.

Or is it just NOT possible? But why would it not?

René

Krumelur
  • 32,180
  • 27
  • 124
  • 263
  • Why do you use a memory-consuming nib for just a UIWindow and a UISplitViewController? For stuff you don't change create them by code. For complicated UI's, use nibs. You don't also use a nib for a generic UITableViewController, right? –  Dec 19 '10 at 10:31
  • Why would a NIB be memory consuming? Objects of the NIB get instantiated just like you would do it in code. I think it is a design decisions: use IB or not. I'd like to use it to have as much of my UI separated as possible. Still I don't know how to achieve what I'd like to do. – Krumelur Dec 19 '10 at 16:09
  • Yeah, I don't know what @user142blablabla is talking about. – Cyprus106 May 06 '14 at 16:30

3 Answers3

2

You can put a UISplitViewController into a different XIB. You cannot have it be the owner, but you can have your app's delegate be the owner and load it when it removes the login view.

  1. Add UISplitViewController IBOutlet to app delegate
  2. Create a new, empty XIB for iPad
  3. Set the File's Owner to your app delegate class
  4. Add a UISplitViewController, connect to outlet in delegate
  5. Add views to split vew controller

Then, you just have to handle your login in the app delegate, load the new XIB, and display it.

ughoavgfhw
  • 39,734
  • 6
  • 101
  • 123
  • Yeah, I came up with something like that (I develop using MonoTouch) and it seems to do the job. Still wondering why they implemented the split view controller so differently. Looks like a kludge. Thanks. – Krumelur Dec 20 '10 at 10:24
  • UISplitViewController can't be the owner of the document because it needs to contain two views instead of just one. It would have been confusing if Apple added extra outlets, because the view outlet should not be changed. – ughoavgfhw Dec 20 '10 at 21:08
  • And the way to get rid of the login view and to add the split view is to remove window.subviews[0] and add the new one? – Krumelur Dec 21 '10 at 08:23
  • Yes. Or, if you have the old view controller, you can call [viewController.view removeFromSuperview]. It takes fewer calls so it will be a little faster. – ughoavgfhw Dec 21 '10 at 19:10
1

maybe not the answer to your question but I have in my App also a login window. What I do is to put the login view above - in my case - TabBar.

  • So you mean you have all your view controlles in the main xib? That's what I had and what works. But logically I think: if a controller is not used in the main method, put it in its own XIB. That's also what Apple tells us in the guidelines - but I can't get it to work with the split view controller. – Krumelur Dec 19 '10 at 16:12
  • no I don't have my login view in the main nib. I have a separate nib for the login and push it over the main-nib. LoginView *loginView = [loadnib]; [self.view presentModalViewController:loginView]; –  Dec 19 '10 at 18:12
  • Oh, I associated "above" with the order of items in IB. Yeah, get your solution. Seems to be a viable option. And by setting the class name of the split view controller in the NIB I can still override it to add some properties I need. Thanks. – Krumelur Dec 20 '10 at 14:06
0

I found this post. Best way to switch between UISplitViewController and other view controllers? It seems it really is not supposed to work. You have to put it in the main xib and then apply tricks...

Community
  • 1
  • 1
Krumelur
  • 32,180
  • 27
  • 124
  • 263