iOS7 Implement UIViewControllerTransitioningDelegate with Storyboard - iphone

Since iOS7 we can create custom transition from view controller to view controller using UIViewControllerTransitioningDelegate which allows fine grained transitions.
viewController.transitioningDelegate = transitioningDelegate;
I discovered that when using storyboard we already had the opportunity to create custom transitions using a custom UIStoryboardSegue but it seems the only way to implement custom transition with a storyboard.
How can I implement a transition delegate while using storyboard ?

Check http://www.teehanlax.com/blog/custom-uiviewcontroller-transitions/.
The idea is to use - prepareForSegue: to set the transitioningDelegate and the modalPresentationStyleto UIModalPresentationCustom. Then your transitioning delegate will have to take care of the transition.

Check out the following example:
https://github.com/soleares/SOLPresentingFun
It's an implementation of the sample code for WWDC Session 218: Custom Transitions Using View Controllers. It uses storyboards.

Related

Show UIViewController partially over a UIViewController with Swift

I would like to show a UIViewController over a UIViewController from the top of the screen (for example, when a button is pressed) and I would like it to be shown only of a part of the screen (for example 50%).
Can it be done?
One view controller can present another view controller modally.
The visual style of the presentation can be one of the predefined ones from UIKit, or you can set
presentingViewController.modalPresentationStyle = .Custom
and then implement the custom animated transitioning which is not a trivial task so its best if you find a step by step guide or watch a WWDC video for that. In the custom implemented transitioning class, it is you who controls the position of the presented view that belongs to the presentedViewController.

Creating a sliding segue in Swift

I am trying to create a segue/transition between two View Controllers that "slides" to the next View Controller. What I mean by "slide" is that it only moves as much as the translation of a pan gesture(similar to Snapchat). If you could help me with this or just point me in the right direction, that would be great.
That effect is achieved using custom interactive transitions, which were introduced in iOS7. Here are a few tutorials to check out:
See Custom Transitions Using View Controllers. https://developer.apple.com/videos/wwdc/2013/
http://www.thinkandbuild.it/ios7-custom-transitions/
http://objectivetoast.com/2014/04/14/interactive-transitions/
http://www.teehanlax.com/blog/custom-uiviewcontroller-transitions/
This one gives many examples of the effects that can be achieved. http://www.appcoda.com/custom-view-controller-transitions-tutorial/
When I was implementing this I found that, for reusability, it was best to have one subclass of UIPercentDrivenInteractiveTransition (which we'll call TransitionManager) that implemented the protocols UIViewControllerTransitioningDelegate, UINavigationControllerDelegate and UIViewControllerAnimatedTransitioning.
- Then, if you need to present a UIViewController modally with your custom transition: in prepareForSegue set:
destinationViewController.modalPresentationStyle = .Custom
destinationViewController.transitioningDelegate = TransitionManager()
- If you're using a UINavigationController it's even easier, all you need to do it set the UINavigationController's delegate to your TransitionManager.
Hopefully that should start to make some sense once you've gone through the tutorials.

Using Storyboards with UIViewControllers that do not have UITableViews

I watched the WWDC tutorial on using storyboards, and can see the benefit if you're using tableviews, but I can't quite see how you would use them otherwise.
For example, if I am using a MKMapView, and I present a pin, and a callout for that pin, if I want to go to my next view controller, as far as I know, I have to go to the next detail view controller in code and cannot use a storyboard or segue in this scenario. Or am I mistaken and there are some added benefit in presenting view controllers through storyboards when you aren't using UITableViews? Thanks.
Segues work when triggered by UI elements other than table cells.
They also work when requested in code. For example, create a segue between two controllers (not views or controls) and it can be invoked from code anywhere in the source controller using performSegueWithIdentifier:(NSString *)identifier sender:(id)sender.

How to create custom view controller container using storyboard in iOS 5

In iOS5 using storyboard feature I want to create a custom container which will have 2 ViewControllers embedded in it. For Example, embed Table view controller as well as a view controller both in one ViewController.
That is, one view controller will have 2 relationship:
to table view controller
to view controller which in turn will have 4 UIImage view Or UIButton in it
Is creating this type of relationship possible using storyboard's drag drop feature only & not programmatically?
,You should only have one view controller to control the scene. However, this viewController might have two other view controllers that control particular subviews on your scene. To do this you create properties in your scene viewController, in your case one for your tableViewController and one for your view. I like to keep things together so I make both these viewControllers outlets and create them in interface builder. To create them in interface builder pull in an Object from the Object library and set its type to the relevant viewController. Hook it up to the appropriate outlet you just created in your scene's viewController - Note: this is important otherwise the viewController will be released if you are using ARC and crash your app. Then hook these viewControllers up to the view you want them to control and you are done.
Alternatively you can instantiate and hop up your viewControllers in your scenes viewController should you prefer to do this.
Hope this helps.
Edit: On reflection this is not a good idea and actually goes against the HIG you should maintain only one ViewController for each screen of content and instead try to create a suitable view class and have the single view controller deal with the interactions between the various views.
There is a way to do it that isn't too hacky. It is described at the following URL for UITabBarControllers, which you could use the first view controller in the list control the first subview, and the second one control the other. Or, you can probably adapt the code to work with UISplitViewController.
http://bartlettpublishing.com/site/bartpub/blog/3/entry/351
Basically, it works by replacing the tabbarcontroller at runtime after iOS has finished configuring it.

UITableViewController without subclassing

Is it possible to create and display a UITableView controller which allows the user to select an item and fire back a message to the delegate without subclassing it?
The reason is I just want to display a list of items in a popovercontroller and it seems a waste to have to create a subclass just for this
In the view controller that presents the popover you could implement UITableViewDataSource and UITableViewDelegate - then set the popover's tableview to use the parent controller as its source and delegate before presenting it.
If you are using iOS 5 SDK then you can make static cells.
Otherwise the only option is to create a subclass and provide a DataSource array.
Either ways you might want to have a View Controller that prepares the view controller loaded on the touch action?