iOS "slide in from left/right" view animations - ios

My iOS6 app has a multi-level table view whose leaf nodes open up separate views. The animation from the first level of the table slides the old view out to the left and the new view in from the right. I'd like to also use this slide-in animation when transitioning from a table view to a non-table view. How?
Here's more info:
On the first level of the table view, there are disclosure Indicators . When one is clicked, the first level of the table slides off to the left and the second level view slides in from the right. Good.
On the second level of the table, there are Detail Disclosure Buttons which take the user to a detail view for that element in the table.
I'd like to offer the same animation here too: the table view should slide off to the left and the new view should slide in from the right.
First, am I correct that this is the correct animation to use in this case?
Second, do you know why this "slide in" animation isn't in the standard view animations in UIViewAnimationTransition below?
typedef enum {
UIViewAnimationTransitionNone,
UIViewAnimationTransitionFlipFromLeft,
UIViewAnimationTransitionFlipFromRight,
UIViewAnimationTransitionCurlUp,
UIViewAnimationTransitionCurlDown,
} UIViewAnimationTransition;
Finally, if I do want to use the same slide in animation that table views use, but it's not available as one of the standard views, how should I add this animation when transitioning between a table view and a non-table view?

Typically this type of animation is done in a UINavigationController, and is the result of pushing a new viewController onto the stack. If you want to simulate it, all you need to do is add the newly exposed view to your current base view, to the right of the current view (i.e. off-screen) and use UIView's animateWithDuration:animations:completion: method to move both the on-screen and off-screen views one screen to the left. (Use the completion: block to remove the original view or leave it in place so you can easily animate it back on-screen.)

Related

how to manage view controllers in a sequential pattern - swift

I'm trying to implement sth like images below. there are some views that should be displayed in a sequential order and a bar above them shows the flow of tasks.
as it is shown, first profile view should be displayed. when the user clicks on Go to Next View Button second view (price view) should be displayed. the top bar shows the current view where we are in it. I've tried PagingMenuController already to create a menu with views and then disable scrolling. but PagingMenuController loads all views at the same time and also i don't know how to go to next menu item within child views. now I'm thinking of a container view might be helpful but i didn't use container view so far and i don't know it's good for my purpose or not.
also i want that top bar without swiping between views (only on buttons) and one enable view at the same time.
any helps would be apprectiated.
Your question is both broad and vague. My answer is also going to be fairly high level. I suggest you follow my outline, and if you get stuck on a particular step, post your code, tell us about the problem you're having, and we can help you fix it.
This is pretty simple. Create custom view controller. Give it a container view at the bottom that would contain the current child view controller. Use view controller transition methods to switch between child view controllers. You'll want to add layout anchors to each new child view controllers to pin all of it's view's edges to the edges of the container view.
Create a custom control on top to show the dot and highlight the title of the current view controller.
If you want the next/previous buttons to be on the child view controllers, put them there, and add a delegate property to all the child view controllers that points to the parent view controller, with next and previous methods.
BTW, in languages, like English, where text is laid out from left to right, I would think your first page would be on the left and the last page would be on the right. (I think it makes more sense for profile to be on the left and pay on the right.)

Xcode + Swift: Showing view on top of another

When my app performs a certain segue, I want the new view to be shown on top of the previous view, like a background. How do I do this?
If this is not possible, is there any way I could programmatically take a screenshot of the previous screen to use as a background for the new screen?
There's a method on UIView, snapshotViewAfterScreenUpdates: than will give you a composite view of the current screen. You could use that for your background.
You might look into custom view transitions to do what you're after though.
Instead of a segue to a different view controller, why not just add the new view to the current controller, place it so that it appears above the first view and then set it as hidden.
When the user taps the action that would trigger the segue (a tableview cell for instance), then instead to triggering the segue, just mark the second view as visible and populate it's content with what you need to display.
With a clear background on the second view, it will overlay the original view. Then you can just add some control to hide it once they're through.

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.

Sliding a UIViewController to pop - as in the Readability app

I'm trying to emulate the sliding UIViewController as seen in the Readability app. You can drag a page to the right and it pops the current view off the stack to go back to parent UIViewController with a sliding animation as in the image: the right-most view was on the top and is being dragged right-wards showing the original table on the left.
I've tried a few of the slidingUIViewController solutions such as ECSlidingViewController but they try to emulate the Facebook/Path behaviour of partially sliding a slidingUIViewController on top of another which is not what Readability does.
I've also tried a standard horizontally scrolling UIScrollView but scrolls like the pages are joined at the sides, as opposed to sliding one view over another.
Does anyone know how they did this?
This can be easily accomplished in few steps. I'm not going to write down all the code you need to write in order to do it, but just the steps you need to take. I will use a master-details terminology where the master view is the one from which you want to present a details view and the details view is of course the one at the top of the navigation stack.
When you want to present the detail view:
1) create an instance of the UIViewController that handles the interactions with the detailView. On iOS 5+ you can store this instance in the childrenViewControllers #property on the master's viewController. If you support a lower OS you should store the instance in an ivar.
2) set the detailView's frame to be outside the screen's bounds; add to detailView a shadow for graphical purposes. Finally add the detailView as a subview of the masterView.
3) (optional) add a pan gesture recognizer to the detailView in order to allow the user to swipe the view back and dismiss it.
4) animate the detailView in the screen's bounds. Make sure the interactions with the view below are disabled (be careful not to disable also the interactions with the detailsView!)
When you want to dismiss the detail view:
1) animate the detailView outside the screen's bounds.
2) remove it from it's superview and delete the reference to it's viewController.
3) re-enable the user interaction with the master view.

iPad Split View "Zoom Down" Table View

I am trying to get a good idea of a good way to add items to a split view for iPad. My idea was where you tap the plus button and the table view scrolls down (quickly) to below the table that is there to a screen where you can enter in the new stuff. Then when you click done it zooms back up to the main table.
Is this possible and/or what is a better way to do a addition for a split view with a table to the left?
the point of using a split view is to flatten the heirarchy of doing things with a table view (basically), so why not when you hit the add button, have a view come up in the detail view (the right hand side) with fields to edit and etc? Or use a popover controller to display the 'add cell' view.

Resources