I have a transition class that has two views in the same view controller. This works ok. I want to apply the same transition to a second view controller. I’m not getting any exceptions, but it isn’t working…
The current transition code is like this:
Custom Transition class
- (id)initWithBaseView:(UIView *)baseView firstView:(UIView *)firstView lastView:(UIView *)lastView
{
if((self = [super init])) {
self.view = baseView;
self.originalView = firstView;
self.nextView = lastView;
}
return self;
}
This is the code that is working:
Single View Controller class
- (IBAction)doTransition:(id)sender
{
MyTransition *transition = [[MyTransition alloc] initWithBaseView:self.view
firstView:self.currentView
lastView:self.nextView];
[transition buildAnimation];
}
I would like to achieve something like this:
- (IBAction)doTransition:(id)sender
{
NSLog(@"%s", __FUNCTION__);
MyTransition *transition = [[MyTransition alloc] initWithBaseView:self.view
firstView:self.currentView
lastView:secondView.lastView];
[transition buildAnimation];
}
- (void)viewDidLoad
{
NSLog(@"%s", __FUNCTION__);
[super viewDidLoad];
secondView = [[SecondViewController *) secondView initWithNibName:@"SecondViewController" bundle:nil];
}
where First View is in the firstView Controller and next view is in the second view controller..
UPDATE:
I’ve updated the First VC as follows:
- (void)viewDidLoad
{
NSLog(@"%s", __FUNCTION__);
[super viewDidLoad];
secondView = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
}
- (IBAction)doTransition:(id)sender
{
NSLog(@"%s", __FUNCTION__);
MyTransition *transition = [[MyTransition alloc] initWithBaseView:self.view firstView:self.currentView lastView:secondView.view];
[transition buildAnimation];
}
Logging the second VC shows that it is not called..
I think it should work if you try something like this:
If i understand what you’re trying to do, then you should be able to perform the same animation on the SecondViewController’s view, just like you would with a regular view. Or am I missing something else?