segue应该执行动画,其中新控制器从屏幕的右边滑动到中心,而旧控制器同时从中心滑动到左边。
我输入了所有应该在逻辑上正确的维度,但是segue执行的运动非常不同。
而不是所需的动画,新的控制器会立即显示在中央,然后滑动到屏幕右侧。
这是我的代码:
UIViewController* src;
UIViewController* dst;
- (void)perform
{
src = (UIViewController *)self.sourceViewController;
dst = (UIViewController *)self.destinationViewController;
float width = src.view.bounds.size.width;
float height = src.view.bounds.size.height;
dst.view.bounds = CGRectMake(width, 0, width, height);
[src.view addSubview:dst.view];
[UIView animateWithDuration:5 animations:^{
dst.view.bounds = CGRectMake(width, 0, width, height);
src.view.bounds = CGRectMake(-width, 0, width, height);
}];
[NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(present) userInfo:nil repeats:NO];
}
- (void)present
{
[[self sourceViewController] presentViewController:[self destinationViewController] animated:NO completion:nil];
}
答案 0 :(得分:1)
变化:
dst.view.bounds = CGRectMake(width, 0, width, height);
为:
dst.view.frame = CGRectMake(-width, 0, width, height);