Domanda

I am looking at implementing some custom IOS7 Transitions. For example these here.

When a button is pressed in this example the following is run:

-(void)showNewController:(id)sender{
    
    UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:[NSBundle mainBundle]];
    UIViewController* controller = [storyboard instantiateViewControllerWithIdentifier:@"PresentedViewController"];

    if(sender == self.button1){
        self.animationController = [[ZoomAnimationController alloc] init];
    }else{
        self.animationController = [[DropAnimationController alloc] init];
    }
    
    controller.transitioningDelegate  = self;
    [self presentViewController:controller animated:YES completion:nil];
}

Question
I am trying to understand the correct place to pass information to the new UIViewController. As an example lets say I am trying to pass a UIImage to the new (to be) presented view controller.

Typically I would complete this in the prepareForSegue method, but as this is not a segue what would be the correct way to pass the data.

I could simply add in as an example the following:

controller.passingImage = self.imageToPass;

Would this be the correct process to follow when working with custom transitions in IOS7?

È stato utile?

Soluzione

The way you setup view controllers doesn't change when you use the new custom animated transitions in iOS 7. So you would still setup the view controller (including setting the transitioningDelegate) in prepareForSegue if you're using storyboards.

See the following sample code for examples of custom animated transitions using storyboards. It's an implementation of the sample code for WWDC Session 218: Custom Transitions Using View Controllers. Look at SOLViewController.m to get started.

https://github.com/soleares/SOLPresentingFun

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top