Storyboards - UISplitViewController with a UITabBarController in the Detail - ios

I am trying to set up a UISplitViewController in a Storyboard with the detail going to a UITabBarController which then goes to a UINavigationController wrapping my first ViewController.
The problem I am having is getting the UIBarButtonItem to show up in the Navigation Item when the device is in the portrait orientation. Should the UITabBarController be the delegate for the UISplitViewController and send delegate message to every child view controller to have them create the bar button item and popover?

I found need for this same solution. I am using it in one of my prototype applications for home-control.
The problem you cite is only the first of a couple of problems you'll run into. I believe i have full the solution now working for both iPad/iPhone (Universal app).
You can read my post here: problem and solution description with sample code at my blog
In summary, you'll run into the following issues (most for iPad imple., some for iPhone imple. when building Universal app.):
The template code in appDelegate sets up delegate incorrectly for the new shape (it really no-longer understands what type of controller is present for the detail view
UISplitViewController delegate calls are not propagated thru the UITabbarController to the tabs correctly
You will need to decide how/when to notify the tab(s) of the current detail selection
When building as Universal App some of the notification now need to happen in prepareForSegue: methods (as some of the other notifications don't happen on the iPhone platform.)
(All of this is shown at my blog post)

You can find example and theory in this site. Very good example.

Related

Deep linking into a storyboard with the correct backstack

I would like to create a "deep link" into my storyboard while preserving the backstack (back button navigation).
Ex:
Given the storyboard below (entry point being the leftmost Navigation controller)
When my application is opened via a remote notification I would like to open the second tab in by tab controller AND be able to navigate back to the item list via the back button.
Please note that I am not asking about how to open the second tab, or how to create such a storyboard but specifically if there is a way to do this with storyboards or will I have to do it by code.
Thanks!
PS: I come from an Android background where one recreates the parent view controller manually or (better) inserts it into the backstack. As far as my research goes there is no such thing in ios. I'm hoping I'm wrong.
Your UINavigationController has a viewControllers property. You can create as many view controllers as you want in an NSArray and assign it to this property and that will be the back stack with the last VC in the array displayed.
The problem is that when a notification arrives, your app could be in any state at all. It could be running, with some other screen showing. It could be suspended, with some other screen showing. Or it might not be running at all, and will now have to be launched from scratch.
Thus, starting in the App Delegate routine that responds here, you will have to deal manually (in code) with the situation if you want to put your app into an appropriate state.

SplitView’s displayModeButtonItem does not show a title on the iPad (iOS8)

I am trying to create a simple split view, Master/Detail, application on iOS8. The storyboard is something like the following:
SVC=SplitViewController
TBVC=TabBarViewController
TVC=TableViewController
SVC---(Master)→ TBVC → TVC -> ASplitViewMaster
|
+---(Detail) → ADetailViewRelatedToTheCurrentMasterView
Bascially, the user touches the “Items” tab, and a tableviewcontroller will appear that shows the kinds of items (i.e. Customers, Foods,etc.). The user touches “Customers”, I want to load a master that shows customers and shows the selected customer’s details in the Detail view. If the user touches a different item (i.e. Foods), then a different MasterView and its related details is loaded.
The project that I’ve created is about 95% towards a working model. It works properly on the iPhone. It works properly on the iPad in landscape mode, but the splitview’s displayModeButtonItem only shows a < without a title on the iPad in Portrait mode. I cannot figure out what I am doing wrong, so I hope that you can help me. I am sure that others may find this view architecture interesting, too, so hopefully this solution will help others in the future.
Here is the sample project on which I have been working…
https://4a1e8691fb88b7b41341-80de7026d6700afa799b216d7fcde2cf.ssl.cf2.rackcdn.com/MultipleMasterDetailViewsWTab-iOS8.zip
Anyway, I would appreciate your help to figure out what I am doing wrong.
Thanks for your time and assistance,
Mike
displayModeButtonItem() method handles the left UIBarButtonItem for you.
The UISplitViewController act differently between iPhones and iPad.
In your case -iPad in portrait mode- the master ViewController is presented as a popover, so you shouldn't have a back button nor a title on it, because you are not trying to go back, you are presenting a popover.
Since iOS 8 there is no UIPopover. The underlying UISplitViewController handles the master (primary) and detail (secondary) UIViewControllers and "vends" the displayModeButtonItem. Ideally, the title of that button should be the title of the top UIViewController of the primary viewController stack. It isn't. I've had some luck, when the master root controller is a UINavigationController, setting its title to match its topLevelController's title, but there are still cases where that technique doesn't seem to work.

self.presentingViewController broken on iOS 8?

I'm experiencing something really weird :
Create an extremely basic single view project, and add a second view controller to the storyboard, along with a modal segue from the first to the second. Initiate the segue from the view controller and trigger it programmatically with performSegueWithIdentifier:.
In the viewDidLoad of the modally presented view controller, add this log :
NSLog(#"%#", self.presentingViewController);
Now run the app on iOS 7, you should get a log like this one :
<ViewController: 0x7fa8e9530080>
Which is just the reference of the initial view controller of the app, which presented the modal view controller.
Now run the exact same thing on iOS 8, and you will get :
(null)
What's going on here ? Is it a known issue ? Of course I'd expect the exact same behavior on both systems.
Thanks ... Formalizsed as answer.
viewDidLoad should really be used for initialization, At this stage, there is not guarantee that the receiver's controllers view hierarchy has been placed in the navigation tree. If that is your intent, you should override viewWillAppear or viewDidAppear. Whilst it works in earlier versions, the docs clearly state that it should be used for additional initialization. It certainly sounds as though in iOS 8, the receiver's initialization is being performed earlier

Making a view Controller stay active (in Background)

I've got a view Controller which manages my TV Playout (HDMI Apple AV Adapter). Everything works fine. I call my view Controller using a popover on the iPad.
When I open the popover, the external screen is recognized and I can work with it. But when I close the popover View (which means I send my TV Playout View Controller to the background) the TV screen (logically) turns black.
Is there a possibility to tell my view Controller to hold the picture on the TV screen by quit?
Like "pseudocode"
[TVOutViewController stayActiveInBackground]; //pseudocode
Thanks in advance!
I suspect you've coded your view controller so it explicitly shuts down the external UIScreen/UIWindow pair when it becomes inactive. I suggest you move the external screen code out of your popup's view controller and into an object which has a lifetime independent of what's going on on the internal screen, e.g. your application delegate or an object referenced by it. Then just send that object messages from your popup view controller in response to user events.
There's nothing about the Apple APIs that causes this kind of behaviour - it's purely a consequence of how you've designed your app. As such I don't recommend trying to force the view controller to stick around. Instead, try to find a better structure for the app. A view controller should only be responsible for its view, not application state.
OK guys, By chance, I found a solution (or at least a workaround). Be sure to manage the problem using a UISplitViewController with your TVOutViewController as the masterViewController and the ContentViewController as the detailViewController. Apple already did the work. Thanks anyway! :)

iPad UISplitView initial state in portrait: how to display popover controller widget?

I'm working on an iPad app that uses a UISplitView. Inspired by http://blog.blackwhale.at/2010/04/your-first-ipad-split-view-application/, I display a button in my detail view when in portrait mode that shows the popover controller. This works great. However, the appropriate UISplitViewControllerDelegate message is only sent when the device rotates. So, when the app first loads (in portrait mode), my navigation button is not visible.
Is it possible to somehow convince the UISplitViewController to send that message on load or something, or do I need to re-implement my own popover logic to get things working?
Thanks,
-Patrick
We had the exact same issue and it turned out that this thread had the right clues. When comparing our app with the SplitView template, we noticed that the split template does exactly what was mentioned here: set the UISplitViewController as the root view controller in application:didFInishLaunchingWithOptions.
Out previous solution linked the split view controller in the XIB directly to the window. While this works it seems the split view has difficulties getting the startup orientation and the missing button occurs. When we removed the link in the XIB and created it in code in the app delegate, everything ran fine.
That's weird. Maybe you missed something. Take a look at the template based on a splitController. It works fine form very startup no matter in what mode the app was loaded.
did you make sure that your UISplitViewController's view is the only subview of your UIWindow, and that you added it inside the application:didFinishLaunchingWithOptions: method of your app delegate

Resources