If I'm creating a universal iPhone/iPad app, I have two XIBs. One main XIB for each device type.
The iPad version is supposed to get a UISplitViewController as the root controller, the iPhone a UITabBarController.
However, the UITabBarController used on the iPhone is exactly the one I would like to use in the iPad's UISplitViewController as the master controller.
What is the best/cleanest way to achieve it without duplicating the UITabBarController?
Do I add a third XIB that contains nothing but the UITabBarController and then add it programmatically? Or is there a more elegant way using Interface Builder's abilities?
Do I add a third XIB that contains nothing but the UITabBarController and then add it programmatically?
Yes, that's what I'd do. There's no Interface Builder support for something like this.
Related
I would like to implement a layered viewcontroller control, where pushed viewcontroller doesn't cover the entire screen but will leave say 20pixela width on the left. If 5 viewcontrollers are pushed and I'm tapping on viewcontroller 2, it should expand, but not remove viewcontroller 3,4 and 5. Only slide them to the right.
The idea comes from the iPad app Trivago and I don't know if they're using an open framework. If not, do you guys have a good idea for implementation? The structure/architecture is fine :-)
If I can create a nice control I will make it public as a cocoapod :-)
Thanks!
Sounds like you may want to do View Controller Containment instead of using a UINavigationController.
See: Creating Custom Container View Controllers
Update:
More examples:
WWDC 2011: Implementing UIViewController Containment
iOS Programming Recipe 28: View Controller Containment & Transitioning
I have a view controller and 5 views. Currently I use a pop-up in mainMenu.xib to access the NSObject AppController which uses the view controller to change between views.
I know that using storyboards in IOS you can use a button within a view to change between views. Is this possible in OSX?
Can I put a button in FirstViewController.xib to access the changeViewController in my AppController object?
Thank you
In OSX your views will appear in a NSWindow. So what you need to do is, upon pressing that button (which fires a IBAction), tell your window (or subclassed NSWindow or NSWindowController) that you want to switch views.
(which you can do via removeSubview or addSubview to the NSWindow's contentView)
You don't have segues or storyboards in MacOS applications, b.t.w.
At the 2014 WWDC they introduced
Storyboards for MacOS X. So IOS Developers can feel more at home creating UI for the Mac.
I created an empty iPad TabBar application using XCode 4, without storyboards. I placed that app in a workspace. I then added the Kal source (obtained from the iPad Juice build) to the workspace as a separate project. The initial build was clean.
I then went to the Kal example (NativeKal) and added EventKitDataSource.h and .m, and NativeCalAppDelegate.h and .m. (The image below shows what files are in the example project)
This is the code from the NativeCalAppDelegate.h file:
I tried setting the first TabBar UIView controller to "KalViewController" as I would normally do when using Storyboards, but it isn't listed in the drop down list of classes.
The question is: how do I get the NativeCal example view controller to replace FirstViewController in the in my TabBar application?
Comments added as Answer.
My recommendation is to switch to storyboards it is a lot easier to do UITabBarControllers in them. You can do this by just creating a new storyboard and copy and paste everything into it and then control drag from the UITabBarController to the UIViewControllers that you want to be linked to the tab bar controller and it does the rest for you, everything else is the same after that. In storyboards you can set the first view controller to be loaded so if you need it to be KalController then you can set it when you set up the UITabBarController. You can also set this in the code. I found that storyboards were a great new feature to xcode, UITabBarCotrollers are a lot easier to do in them then in .nib files I could never get them to work.
Hope this has helped.
I've been wondering what i should use these classes for. I would think it's to set up the appropriate main view on the device. By default there's only a dealloc method added to these classes, so I figure I setup my iPhone view in the *AppDelegate_iPhone class in the -init method, yet whatever I do, I'm not able to change the background color or add a subview on the main window using this class. Perhaps I should use this class for other purposes and just use the normal AppDelegate to setup my view hierarchy for each device?
You would do stuff common to iPhone and iPad in AppDelegate and the differences in *AppDelegate_iPhone/iPad and inherit AppDelegate. If there are no differences just delete them and change the class of the delegate in both iPhone/iPad main windows to the one and only one AppDelegate.
And init will be the wrong place, IBOutlets will be nil at this place. Put your code inside applicationDidFinishLaunching.
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é
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.
Add UISplitViewController IBOutlet to app delegate
Create a new, empty XIB for iPad
Set the File's Owner to your app delegate class
Add a UISplitViewController, connect to outlet in delegate
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.
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.
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...