Split view MasterViewController with multiple table views - ios

I have a split view working great. However, I'd like to be able to drill down on my Master-Detail view's UITableView. For example, I have a list of ages: 0, 1, 2, 3, 4, 5. When the user presses 3 I would like a new UITableView to be presented with all the kids names that are 3.
Ideally I'd like use Storyboards to accomplish this (link an add button to take me to the next UITableView). When I try and add a view it shows up as a full screen view. How can I make this view show up in the Master section of the split view?

When using Storyboards, if you want to have multiple UITableViews so it will allow the user to drill down categories, you must use the Push Segue (set it to Master). Make sure you are not pushing a UINavigationController, but just the view you want listed. Then, to get back just use [self.navigationcontroller popViewControllerAnimated:YES];.
EDIT: (more info as asked for)
So in XCode/IB when you are on your main view and right click and drag it to another view, you will be presented with different choices. You want to select Push instead of Modal. This will allow it to push a new view onto the stack. You can also set it's destination to Master and it will size the IB view correctly.
Also, you don't always have to use a button to connect a view. You can also drag from the view controller itself to another view controller instead of a button to view controller. Then in your button code you can call [self performSegueWithIdentifier:#"someNameHere" sender:self]; to call the transition. This lets you do checks and validation before you move on to the next screen.
Just remember to click on your segue and name it (under identifier in the properties view). Then add the function prepareForSegue:sender: in order to transfer any variables or anything before it transfers (I rarely have to use this).

Related

Dismissing view controllers with no fixed order

I'd like to know the best way to handle view controllers when there are multiple ways for the user to navigate through an app. The problem is that the user might (for example) trigger a segue by selecting a table row, Then, from the presented view controller they might click a button in a custom toolbar to go somewhere else.
I'm pretty new at this, so while I understand using a segue to present a view controller, and then having to dismiss the presented view controller at some point, I'm less clear on how to manage things when a user has free reign to go wherever they want! I'm using container views to embed a header and a custom toolbar at the bottom of each view. Should I be using a container for each view controller as well?
If you are quite down the stack and you don‘t want to offer a back button for simplicity, then you go up the stack by calling dismiss and tell the delegate where you want to go until you reach the appropriate level which can move you up until you are where you wanted to go.
The alternative is to move up the delegate chain until you can move down again and from there call dismiss and then go down where you want to go.

How to load different Master&Detail view controllers on button click?

I am new in Objective-C programming. I have developed an iPhone App and everything went Ok. Now I want to create the iPad version of the same App.
I started creating a split view controller. The problem is that I am not figuring out how to manage the master and detail views.
I want that my iPad version of the App behaves something like this:
When it is first run I want only to show the Master View Controller like in the photo:
And I want empty the part of the Detail View Controller. Also when the user changes the iPad orientation to portrait and the detail view controller is empty I want to show the Master view and not the detail view, otherwise is the detail view controller is not empty, on orientation I want to show the detail view.
Then onClick of the first Enter button in the Master View Controller I want to load a view for the Detail View just like in the photo:
Then on click of the button in the Detail View I want to load completely new Master and Detail Views :
I have read and seen different tutorials on managing split views but they all try to explain the use of Table View Controllers with Split View Controllers and I've nowhere found something similar to what I need.
I am not sure that you actually can leave the details view empty. I haven't tried it. Instead, make a view-controller with only white empty view, and place it at first.
I recommends you to put UINavigationController on each pane, and push your custom VCs into each NCs. Then you can perform push/pop/swap sub-VCs in NCs.

Use case for push versus modal segues?

Let's say, I have a scene (pushed view controller with a navigation bar), which displays some tabular data in a table view.
In the navigation bar of that scene I have a + sign, which should open a new scene, where the user can add a new item (row to a core data table).
In the table view, each row has an arrow on the right side of each cell, which opens a scene where the user can edit that particular item's details.
Should I use a push or modal segue for the +?
Should I use a push or modal segue for the arrow?
What is the "best practise"?
I understand the difference between push and modal segues, but I want to know which is better suited for the above use cases.
If you want to follow Apple's best practices, I would suggest the following :
For the "Add" functionality, use a modal segue.
For example look at the contacts app. Pressing + shows a modal view controller.
What's the logic ? for start, modal view controllers usually have a "cancel" button, as opposed to the "back" button on a pushed vc.
When the user presses "back" - he'd expect a way to come back to the vc. Usually "back" saves your data on iOS (auto-saved).
So by using a modal segue you force the user to submit the form , or cancel. The modal presentation hints that you really need to fill this screen.
For editing - push. but modal could work as well (and you could reuse the same VC).
Reasons for push :
you get a hierarchy of vc's , going back and forward while drilling down.
(you should implement) auto saving when going back (just like other iOS apps)
For adding a new entity to the core data table, on tapping the + button (I assume its a right bar bar button item on the navigation bar), use the modal segue.
The view for adding a new row for the enity has to be presented modally and once the save is completed, dismiss the modal view and reload the table view to display the newly added item.
Also for displaying the details of an entity row, use the push segue. A user expects a push action when he selects a table cell and it is the ideal way to do that.
I hope this quick summary will help you :
When you want to show a detail view of a summary view, use a navigation controller and Push Segues. If the "parent" view doesn't really relate as far as data is concerned to the "child" view, then use a modal. A good example for a modal view would be any entry view. This view doesn't really have any relationship as far as data is concerned to the "parent" view., the entry screen will just take data dat from user & will save & can go away & giving control back to parent

Designing view on top of multiple embed views

I have the task to design a application that has a main view which is always visible (it has a button on it's bottom side, and when pressed a image displays on top of all views), and a set of TableControllerView's that should appear under it, and the user needs to be able to navigate through them.
I know that you can embed a view inside another, but you cannot refer more than one view to it. The current way I'm trying to do now load one TableViewController inside the embed view, and when the user clicks the cell I manually load the other controller and add it as a child of the main view, which is the RootViewController. The problem with this approach is that the navigation bar gets stuck using the root view controller, so I have to manipulate the main navigation items on each subview transition, and second is that the frame for the second view I load is coming as it had full size, making some cells be under the main view button. This way doesn't uses segues for transition, so it makes the storyboard kinda useless.
I was thinking into using a TabViewController with it's tab hidden, but wanted to ask here for a better solution.
As you discovered, a TableViewController likes to fill up the whole screen (except navigation bars, tab bars, status bar, etc. which are official Cocoa Touch GUIs). When you want a table view to fill only part of the screen, you are supposed to use a UITableView but not a UITableViewController. You set your custom view controller object (subclass of UIViewController, not UITableViewController) as the table view delegate and data source. You will need to duplicate part of the functionality of UITableViewController in your custom view controller, but it's not a lot more than you have to do already to supply the data.
You should probably follow the standard design pattern and have separate view controller objects for each of the "pages" the user can navigate to. You just have a main button and image on each of them. But I could imagine why that might not give you exactly the effect you want.

Maintaining popover across multiple detailviews in UISplitView

In my app delegate I create a UISplitViewController. I set the delegate to be the detailViewController.
When I run my app in portrait, I have the left top popover button showing that will slide out the split view master.
Then I have a button in my detail view that resets the splitviewcontroller array with a new detail view controller and sets the split view delegate to that controller.
The second detail view displays properly... but I lose my popover button on the second view controller.
Does anyone know how I can get that button to remain on all of my detail view controllers I may add?
Thanks!
See http://www.raywenderlich.com/forums/viewtopic.php?f=2&t=1546 for what I find to be a good approach.
It involves setting the SplitViewController delegate to be the master instead of the detail. The master keeps references to the popoverController and the button, and each time the delegate methods are called (hide and show master) it gets the current detail view and performs the necessary action (add in the button/remove button and popovercontroller).
The master defines a protocol for "SubstituableDetailView" which contains the two methods for showing/hiding the button.

Resources