Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/99.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用动画向左/向右滑动两个UIView不精确_Ios_Animation_Uiview - Fatal编程技术网

Ios 使用动画向左/向右滑动两个UIView不精确

Ios 使用动画向左/向右滑动两个UIView不精确,ios,animation,uiview,Ios,Animation,Uiview,我在设置左/右两个UIView的动画时遇到问题。它基本上是一个推/弹出式动画。问题是,有时它们不会粘在一起,而且它们之间的背景色(垂直线)是可见的。这不是每次都会发生,但很烦人,我不知道自己做错了什么 编辑: 这仅在实际设备上发生。在iOS模拟器(普通或视网膜)上,垂直线在任何时候都不可见,动画非常精确 简而言之,这是我的代码: UITableView *table1 = ... UITableView *table2 = ... table1.center = onScreenCenter;

我在设置左/右两个UIView的动画时遇到问题。它基本上是一个推/弹出式动画。问题是,有时它们不会粘在一起,而且它们之间的背景色(垂直线)是可见的。这不是每次都会发生,但很烦人,我不知道自己做错了什么

编辑: 这仅在实际设备上发生。在iOS模拟器(普通或视网膜)上,垂直线在任何时候都不可见,动画非常精确

简而言之,这是我的代码:

UITableView *table1 = ...
UITableView *table2 = ...
table1.center = onScreenCenter; // This is the center of the screen
table2.center = leftOffScreenCenter; // This is the on screen center - width of the table2
CGPoint rightOffScreenCenter = ... // The right offscreen

[UIView animateWithDuration:kSearchBarAnimationDuration
                          delay:0
                        options:UIViewAnimationOptionCurveEaseOut
                     animations:^{
                         table1.center = rightOffScreenCenter;
                         table2.center = onScreenCenter;
                     } completion:nil];

我会尝试在动画完成后在完成块中设置坐标,并且CGPoint坐标是浮动的,也许,以防万一,最好最终使它们成为整数。只是想法…您是否尝试查看onScreenCenter、leftOffScreenCenter等值,看看它们是否总是相同的?每个视图的起点和终点之间的距离是否相同?因为您使用的是
UIViewAnimationOptionCurveEaseOut
,所以可能其中一个视图开始比另一个视图慢。您还应该查看变量值是否四舍五入。谢谢您的建议。我已经在完成块中设置了坐标,并对浮点进行了四舍五入(只有Y坐标是浮点数),但它仍然在发生。我还用NSLog检查了距离,每次都是一样的——每个tableview都以262px的速度移动。
UITableviews
有什么特别之处吗?