ios transitiondelegate with segue - ios

I have implemented a transitiondelegate, and assigned it to the destination viewcontroller in the segue (at method viewDidLoad). My question is: How iOS knows to use the same delegate when peforming the segue from source to destination? I mean, I didn't assign the delegate at the source viewcontroller. Only assigned it at the destination, and still it is being called when performing the segue.
Who should have the delegate? The presentingViewController or the destinationViewController?
I would expected it to only be called when doing a segue the opposite way.
Thanks, and hope I was clear.

Before the transition, the destination view controller asks its transitioning delegate, for the animation controller.
You should set the transitioning delegate for the destination controller.

Related

Segue related functions

I know, I can programmtically do segue action by using:
-performSegueWithIdentifier:sender:
I also know the other segue related method on UIViewController, -prepareForSegue:sender:, in which I can do customization on the destination view controller.
But I am wondering, which one is called first?
say in a scenario, there is ViewControllerOne that has a button which triggers the -performSegueWithIdentifier:sender: , then goes to ViewControllerTwo.
The first is performSegueWithIdentifier:sender: and actually this is the one you performed.
The second call you mentioned prepareForSegue:sender: is a delegate call, which you are not forced to implement
Got it myself:
Before performSegueWithIdentifier
Before prepareForSegue
After prepareForSegue.
After performSegueWithIdentifier

How to select ViewController?

The app starts on ViewContoller
I push TutoViewContoller
On some action, I pop TutoViewContoller
I would like to call a method of ViewContoller just after popping TutoViewController. How can I do that ?
You can implement viewWillAppear of ViewController. If you really need to distinguish between TutoViewController and other viewcontroller you have many options to call before you pop it: delegate pattern, passing reference of ViewController to TutoViewController etc.

Cannot programmatically perform segue

I have a storyboard segue with an identifier that is 'Push to ResumeView'.
I try calling it in the ViewController that I'm in at the point, by doing
[self performSegueWithIdentifier: #"Push to ResumeView" sender: self];.
But nothing happens?
I'd much rather just push the ViewController using the top NavigationController or something, but I can't see how to do that either.
Try implementing the shouldPerformSegueWithIdentifier:sender: or prepareForSegue:sender: methods in the 'from' view controller. Put a break point or NSLog() inside the method to inspect the segue identifier. This will prove that you indeed set up the segue correctly in the storyboard.
If you want to manually push your next view controller to the top of the navigation controller, use pushViewController:animated:. However, if you are using storyboard, the preferred way is to use segues.
Try this one.
UIViewController *yourResumeView=[self.storyboard instantiateViewControllerWithIdentifier:#"PushToResumeView"];
[self.navigationController pushViewController:yourResumeView animated:YES];

segue not going to destination controller

In my app I have a manually triggered push segue called "details". It is wired from the source controller to the destination controller and it's identifier is set. In my code I call
[self performSegueWithIdentifier:#"details" sender:sender];
I can see the prepareForSegue function firing and have verified that the destination controller is of the proper type. I pass the destination controller a few bits of data it needs to display correctly. Oddly enough NOTHING happens. The app does not go to the destination controller.
Here are some things to look out for if you are having an issue with performSegueWithIdentifier while using a storyboard
You have correctly hooked up your transitions in your Storyboard
Your Segue Identifier matches the one on your Storyboard
Your ViewController's class has not become deallocated
(This can sometimes occur accidentally by calling from another class)
Try setting sender to "self" rather than sender
Also, if you are planning on passing data between ViewControllers it is suggested that you use the prepareForSegue method, allowing you to pass values before segue'ing.

Segue from UIImagePickerController

I'm trying to make a segue from a UIImagePickerController to another view controller.
I have tried a push segue, because I knew that UIImagePickerController was a subclass of UINavigationController, but it didn't work. The error is "Push segues can only be used when the source controller is managed by an instance of UINavigationController."
Now I try a modal segue, but when it occurs, the screen goes black.
Is there a link between the two problems, and how can I do please ?
You cannot perform segue directly from a UIImagePickerController.
Try to add a push segue from the view controller that instantiates the UIImagePickerController to the target VC.
Now implement UIImagePickerControllerDelegate method didFinishPickingMediaWithInfo: in your source VC and inside that method call self performSegueWithIdentifier: sender: with the segue identifier of the segue, you have created lately.
Of course, you need to set an identifier for the segue and add UINavigationControllerDelegate, UIImagePickerControllerDelegate protocol references in your source VC header interface.
Also you might need to implement prepareForSegue: method in your source VC if you need to pass some data (such as image information) to the target VC.

Resources