Swiping between UITableViewController detail items - ios

I have a UITableViewController derived class. In tableView:didSelectRowAtIndexPath:, I create a detail view controller vc and push it with [self.navigationController pushViewController: vc animated: YES];.
On that detail view, I want to be able to swipe left and right and go to the previous/next item detail, or back to the table view if it's on the first/last item. I implemented the swipe and back functionality using [self.navigationController popViewControllerAnimated: YES];, but I'm not sure about how to implement the detail -> detail paging. I thought about using the same pop, then calling tableView:didSelectRowAtIndexPath:, but tracking and modifying the index path and tracking the tableView seems like a clunky way. Is there a better way?
Also, when I pop the view controller, it always slides off to the right. Is there a way to animate it sliding off to the left (to simulate a right to left swipe on the last item)?

The best way to do what you're trying to do is to present your detail contents in a UIPageViewController. It is a collection view controller, kind of like a table view controller. It has a delegate and data source like a table view does. It asks you to give it view controllers that present pages of content. You can set it up to slide from page to page or page curl, and optionally add a book spine. There is a sample app from Apple called PhotoScroller that shows how to set up a page view controller for sliding back and forth. It does a lot more than that, but you can ignore the content view controllers it uses and substitute your own detail view controllers.
You would share the data model between the table view and the page view controller.

Related

Partial segue to show settings view

in the google maps app for ios. When you select the settings button, it will show you a view of options such as "traffic", "public transit", etc.
My question is how this is done on ios.
I tried following this tutorial but it says that it won't work on uinavigationviewcrollers. I have seen this partial segue of the the view in apps that use a navigational controller. How do they create that?
It's not a partial segue. It's not a segue at all, it use of containment view controllers.
Instead of a single view controller which transitions to a different view controller image one single master view controller. For simplicity, we'll say this view controller has two views (of the root), both of which cover the the whole screen. For this example let's think of them as "main" view and "menu" view.
Other than these two empty views, the view controller has no content. That's because this view controller does nothing other than manage other view controllers which get stuck into the two views. It will have a couple methods manage them, like presentInMainView:(UIViewController *)viewcontroller and presentInMenuView:(UIViewController *)viewcontroller
When the program starts running the master view controller will programmatically add the map to it's "main" view. The map view controller now cover the whole screen and looks and acts like it's the top level view controller, but it isn't. It's contained. At some point some taps the settings button and the map view controller will make a call to it's parent and say presentInMenuView:... and the master view controller will then load up a second view controller into the menu view. The menu view could even be located off the left side of the screen and the master view controller animates the menu view frame to side it right covering the whole screen. Assuming the menu view controller only has content which covers the left half of the screen you'll see the map view controller hiding behind it.
That really only scratches the surface, lots can be done with container view controllers. You could create a container which lets you brings up a dozen different views all populated with view different view controllers. You could size and arrange them on all over the screen and each child view controller could still only have to deal with it's own contents.
For more info there is the Apple Developer Guide and the WWDC 2011 Videos where it was introduced (session 102)
I used SWRevealViewController For similar type of sidebar animation.They given the good example of how to use SWRevealViewController also please try it once.

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.

detecting indexPath row and pushing a new view controller to a split view controller

I have a split view controller that has a table on the left hand side, and a empty detail view controller on the right had side. For iphone, I know its possible to push a view controller and a nib in a navigational stack. I want to know if its possible to push a view controller + nib on the detail view, after a user taps the table cell.
I tried simply pushing the view i have after a user taps to the detail view, however nothing happens.
To do this you'll need to make sure you have a UINavigationController on the detail side of your split view controller. You can set a navigation controller as the detail item within the nib that contains the split view. You can set the navigation controller as the split view delegate and use the delegate property to push views onto the stack in response to events happening on the root view side.
ya u can do that check out this example here
http://developer.apple.com/library/ios/#samplecode/MultipleDetailViews/Introduction/Intro.html
and to make navigation controller in detailview of split view check example here
http://www.cimgf.com/2010/05/24/fixing-the-uisplitviewcontroller-template/
i think it will help you
Have you tried just going to the developer.apple.com and use the standard example from Apple, which does exactly what ur saying?
Cell 1 = loads Xib1
Cell 2 = loads Xib2.
Maybe give that a go..

Resources