我有一个转换类,它在同一个 View Controller 中有两个 View 。这工作正常。我想将相同的转换应用到第二个 View Controller 。我没有遇到任何异常,但它不起作用......
当前的转换代码是这样的:
自定义转换类
- (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;
}
这是正在运行的代码:
单 View Controller 类
- (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];
}
其中第一个 View 位于第一个 View Controller 中,下一个 View 位于第二个 View Controller 中。
更新:
我已按如下方式更新了第一个 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 显示它未被调用..
最佳答案
我认为如果你尝试这样的事情应该会起作用:
- (IBAction)doTransition:(id)sender
{
NSLog(@"%s", __FUNCTION__);
MyTransition *transition = [[MyTransition alloc] initWithBaseView:self.view
firstView:self.currentView
lastView:secondView.view];
[transition buildAnimation];
}
- (void)viewDidLoad
{
NSLog(@"%s", __FUNCTION__);
[super viewDidLoad];
secondView = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
}
如果我明白你想要做什么,那么你应该能够在 SecondViewController 的 View 上执行相同的动画,就像使用常规 View 一样。还是我还漏掉了其他东西?
关于uitableview - ios6 中 View Controller 之间的自定义转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14591860/