0

I'm perfroming a simple view transition using the code below:

 int controllerIndex = 1;
    UIView * fromView = self.tabBarController .selectedViewController.view;
    UIView * toView = [[self.tabBarController.viewControllers objectAtIndex:controllerIndex] view];

    // Transition using a page curl.
    [UIView transitionFromView:fromView toView:toView duration:0.8
                       options:(controllerIndex > self.tabBarController.selectedIndex ? UIViewAnimationOptionTransitionCurlUp : UIViewAnimationOptionTransitionCurlDown)

                    completion:^(BOOL finished) {

                        if (finished) {
                            self.tabBarController.selectedIndex = controllerIndex;
                        }
                    }];

Is there any way that I can pass the id of the view i am transitioning from so I can then perform some logic. i.e. if transitioning from view with id do this....

Thanks,

Matt

user1419810
  • 836
  • 1
  • 16
  • 29
  • Who do you want to pass the id to and where do you want to perform the logic? If you want to perform that login in animation block or completion block, you should simply be able to use the view objects. – dispatchMain Aug 23 '15 at 07:49

1 Answers1

0

There's a couple ways to do this:

1)

Subclass UIView to add in an identifier. This could be as simple as:

@interface MattView : UIView

@property (strong) NSString *identifier;

@end

in Objective C or

class MattView: UIView
{
    var identifier : String?
}

in Swift.

Then you can cast your transitioned views to MattView and get the identifier out of them.

2)

You can also use an extension on UIView to add an identifier, or in this related question's answer, a "string tag".

Community
  • 1
  • 1
Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215