#1
  1. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2010
    Location
    California
    Posts
    42
    Rep Power
    0

    How to animate when no reference to target view?


    Hi,

    In my iOS5 app for iPhone, I have something like this

    AppDelegate
    ivar ViewController1
    ivar ViewController2


    ViewController1
    ivar view1
    ivar button1
    IBAction animateToView


    ViewController2
    ivar view2


    Now I want to animate from view1 from viewcontroller1 to view2 from viewcontroller2 by pushing a button in viewcontroller1.
    Bu I do not have a reference to the view2 to the viewcontroller2 in viewcontroler1.

    If I hook the button to an action/target and use block based animation in it
    this one >>

    [UIView transitionFromView:<#(UIView *)#>
    toView:<#(UIView *)#>
    duration:<#(NSTimeInterval)#>
    options:<#(UIViewAnimationOptions)#>
    completion:<#^(BOOL finished)completion#>]
    I am unable to fill in the toView: because of those missing references.

    What would you recommend? IS it even good to solve thi by action target?

    Thanks.
  2. #2
  3. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2012
    Posts
    12
    Rep Power
    0
    You need to create a instance of ViewController2. And then pass that view2 to the transition. Check this out -

    ViewController2 *twoVC = [ViewController2 alloc] initWithNibName:@"ViewController2" bundle:[NSBundle mainBundle]];
    [UIView transitionFromView:view1
    toView:twoVC.view2
    duration:0.5
    options:UIViewAnimationOptionTransitionFlipFromLeft
    completion:^(BOOL finished){
    /* do something on animation completion */
    }];

IMN logo majestic logo threadwatch logo seochat tools logo