Disabling the detail view controller in a split view controller on the iPad in iOS 5 - ios

I have a split view controller in my iPad app. It has a list of Tenants for a mall on the left side and detailed information about the selected tenant on the right.
When you press the edit button on the master view controller (list of tenants) it should disable the right view controller (the detail view for the tenant). How do I accomplish this?
The only thing I can think of is adding a UIImageView with a semi transparent background and hiding/showing it when the master calls it's setEditing.
This functionality ships with the iPad. If you open up the Messages.app and hit the edit button in the master view (left), the conversation or detail view (right) becomes grey and disabled and you cannot interact with it until you hit "Done" on the left side. How can I do this in my app?

So long as the right view controller is the delegate of the master (which should be created for you anyhow, seeing as that's how the UISplitViewController object is supposed to be used), it's a simple call to a method you define yourself. Maybe pass some Boolean value through to indicate editing, and animate a black CALayer's alpha property in response.

Related

State Restoration in Tab Bar and Navigation Controller App

Goal: I'm trying to restore state on a tab controller-based app (with navigation controllers on each tab).
Problem: On relaunch, the selected tab seems to be restored as expected, but the navigation hierarchy inside said tab is not.
Development:
I first started with the project template "Tab based app".
Next, I added restoration IDs to both child view controllers and the tab bar controller.
In the app delegate, I implemented application(_:shouldSaveApplicationState:) and application(_:shouldRestoreApplicationState:).
I run then app, switch to the second (right) tab, hit home, terminate. o relaunch, the right tab is displayed (as expected). So far so good.
Next, I go to the storyboard and embed both child view controllers in respective navigation controllers, and assign restoration IDs to those too.
I run the app, and restoration still works. Still good.
Next, I add a "detail" view controller; its class is a custom subclass of UIViewController to the storyboard, with properties to configure the contents of a debug label and its view's background color.
I placed a "Show Detail..." button on each of the tabs' top view controllers, and create a segue from each into the (shared) detail view controller. So now my storyboard looks like a hexagon (also, both segues have identifiers set in Interface Builder). So, both left and right top view controllers share the same type of "detail" view controller. On show, it is configured so as to distinguish from where it has been pushed (see next point).
On each of the top view controllers' prepareForSegue(_:sender:) method, I configure the pushed detail view controller differently: Different text and background color ("left" and blue, and "right" and red, respectively).
I added code to the detail view controller to save and restore the state of the text and background color properties: encodeRestorableStateWithCoder(_:) and decodeRestorableStateWithCoder(_:). Also, I implemented viewDidLoad() so as to reflect those properties' values in the view. Whenever it is instantiated and pushed into the navigation through a segue, the properties are first set and then used to configre the view in viewDidLoad(). Whenever it is instantiated during restoration, the properties are set in decodeRestorableStateWithCoder(_:) and similarly used in viewDidLoad().
...but when I run this code, the last selected tab is restored but only up to the top view controller -left or right-, not the detail. Interestingly, the background color last set to the detail view controller flashes for an instant.
I placed break points in encodeRestorableStateWithCoder(_:) and decodeRestorableStateWithCoder(_:), but only the first of them is executed (encode).
Wondering what might be missing, I went ahead and implemented the app delegate's application(_:viewControllerWithRestorationIdentifierPath:coder:)(returning always nil, but logging the path components passed).
The documentation is not very clear on whether this method is needed or not, and in any case all view controllers except the detail seem to be restored perfectly even without it. I added code to instantiate each view controller based on the last path component (i.e., that controller's restoration ID) and returning it.
Now, the decodeRestorableStateWithCoder(_:) is called, but the navigation still goes back to the tab's top view controller after a split second.
So, what is going on? What am I missing to implement State Preservation and Restoration in a Tab Bar + Navigation Controller app?
FIXED: So, there were several problems with my code...
It turns out that in my case, I do not need to implement application(_:viewControllerWithRestorationIdentifierPath:coder:). (see the comments of this answer)
My implementations of encodeRestorableStateWithCoder(_:) and decodeRestorableStateWithCoder(_:)
were not calling super (as suggested in the accepted answer to the question above).
finally, I got the right view controller (detail) to appear, but its subviews' state (text label contents and main view background color) were in the initial, empty state (not being restored to their last state -i.e., text label contents and bg color). As mentioned in this question, the viewDidLoad() is not called right after decodeRestorableStateWithCoder(_:) (like I assumed), so instead I call a common method from both viewDidLoad() and decodeRestorableStateWithCoder(_:) to update the UI.
As usual, I rushed to post a question before searching or trying enough modifications in my code (my apologies...).
I hope this at least helps someone else.
As usual, I'll wait a couple of days before accepting my own answer, in case somebody sheds additional light.

Displaying user information on an popover alert view controller

I am working on an app for a Cafe where users can "sign in" to their seats.
Currently I am thinking of a way to present basic user information of seated people. What I am envisioning is to when the table gets tap, a square information box (pardon my primitive language) appears in the middle with the background being blurred out. I am hoping to have something flexible so that i can add tab and such to this so called box.
I have been looking at popover alert controllers and apparently there is limited information on them in regards to the iPhone. Is there a reason why popover view is not used for iPhones as compared to iPads? Moreover, is there a smarter UI to handle this or should i just segue to the next view when tapped.
Basically, popovers are iPad-only because iPhone screens are too small to make them effective. UIAlertController is a similar alternative, though it may not lend itself to what you're trying to accomplish.
Segueing to a new view for the user information is definitely a solid option, or if you want to preserve the feeling of staying on the same view you can animate a custom view over top of your current view, often from the bottom in the style of a keyboard or the settings drawer.
I think you are mixing up two different concepts: Alerts vs View Controllers being displayed modally.
Alerts – as the name suggests – are used to bring something important to the attention of the user. They usually interupt the current flow.
View Controllers presented modally are similar to what you discribe: a new View Controller moves over the current one, and the current one is blacked out to put emphasis to the new one. As you rightly pointed out though, this is hardly used on iPhone: This is because iPhones historically have rather small screens, and scaling down a view controller leaves hardly any room for content.
View Controllers presented as popovers is yet another thing: Here, you show the new view controller in a separate window that originates from a specific point in your UI.
This document might be of interest for you.
You may want to use a Modally presented View Controller. For this, you will create the view you want to pop up in a separate view controller. Then, control-drag in a segue from the parent view to the Modal of type Present Modally. You can even get your blurriness by setting your Modal's background to clear and adding a Visual Effect with Blur to its view.
Now, give the segue an identifier in the right hand pane so you can call it programatically.

How to arrange Tabbar on the left side of the screen

I am developing one iPad application using storyboard.For my application i need one tab bar on the left side of the screen.I do not want external liberies for tab bar.Is this possible to arrange the tab bar available in the story board arrange on the left side of the screen.
Like already mentioned, use split view controller which will separate your iPad UI to two parts:
Master view controller - This is usually a table view or collection view that display all elements.
Detail view controller - This displays the detail of selected item in master view controller.
You can communicate between them with delegates, NSNotificationCenter or observers.
You can easily add separate UITabBar views to both master and detail view controller.
You can also read more about it on the links below:
http://www.raywenderlich.com/29469/ipad-for-iphone-developers-101-in-ios-6-uisplitview-tutorial
Good iPad SplitViewController tutorial?

iPad UI navigation - split view with horizontally scrolling views

I'm looking for suggestions to implement a specific UI navigation pattern on iPad. It's not radically different from standard behaviour, but I'm unsure of the best approach to use.
Picture a standard split view, with a master view on the left, detail on the right. I want an action in the detail view (e.g. button press) to navigate to an additional detail screen by scrolling from right to left. The result is that the original detail view is on the left (with its width unchanged), and the new detail view on the right. A back button in the nav bar reverses the process. When the master view is visible, the back button is replaced by a menu button in the nav bar (show/hide slide out menu).
I've seen a few similar implementations in existing apps. One that's easy to reference is Shopify's
online demo. Adding an item to the cart and pressing the total button triggers the navigation behaviour.
Any pointers on the best way to implement this would be much appreciated.
Thanks.
Creating a custom container view was a good solution.

"Slide" segue between UITabBar views

My iOS 5 app uses storyboarding with a UITabBarController. There are three "tabs" each displaying a view controller which has been linked using a relationship back to the UITabBarController. At the moment each view controller appears when you tap the relevant tab, as expected. However, for a more gracious transition I would like to slide the view controllers on and off screen.
By way of example, if I am currently on Tab 0 and then select Tab 1 the view controller on screen (for Tab 0) should slide off to the left-hand side of the screen, and the new view controller (for Tab 1) should slide on from the right-hand side of the screen.
I have been able to achieve this behaviour using a custom UIView as the tab bar but would like to know whether this is possible with a custom segue in storyboarding, as that would certainly save a lot of coding (and also would keep things a fair bit neater in the project)?
Thanks in advance for any assistance.
I am trying to do the same thing.
Unfortunately I think the relationship segue does not allow any customization as it just connect tab bar and the tab bar items together, and not a transition.
My guess is we have to do the transition ourselves when the view appeared.

Resources