我有一个在同一个视图控制器中有两个视图的转换类。这工作正常。我想将相同的转换应用于第二个视图控制器。我没有任何异常,但它不起作用......
当前的过渡代码是这样的:
自定义转换类
- (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;
}
这是正在工作的代码:
单视图控制器类
- (IBAction)doTransition:(id)sender
{
MyTransition *transition = [[MyTransition alloc] initWithBaseView:self.view
firstView:self.currentView
lastView:self.nextView];
[transition buildAnimation];
}
我想实现这样的目标:
- (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];
}
第一个视图在第一个视图控制器中,下一个视图在第二个视图控制器中。
更新:
我已将 First VC 更新如下:
- (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];
}
记录第二个 VC 表明它没有被调用..