Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/112.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 设置UITableView宽度动画时,UITableView单元格中的UIButton将跳转_Ios_Uitableview_Xamarin_Xamarin.ios - Fatal编程技术网

Ios 设置UITableView宽度动画时,UITableView单元格中的UIButton将跳转

Ios 设置UITableView宽度动画时,UITableView单元格中的UIButton将跳转,ios,uitableview,xamarin,xamarin.ios,Ios,Uitableview,Xamarin,Xamarin.ios,当执行动画以减小tableview宽度时,在动画实际开始之前,“垃圾桶”按钮首先跳到左侧。 动画在ViewController中执行 UIView.Animate(0.05d, 0.15d, UIViewAnimationOptions.CurveEaseInOut, () => { OrderProductsTableView.Frame = new CGRect(LeftPanel.Frame.Width + 130f, OrderProductsTableVi

当执行动画以减小tableview宽度时,在动画实际开始之前,“垃圾桶”按钮首先跳到左侧。 动画在ViewController中执行

UIView.Animate(0.05d, 0.15d, UIViewAnimationOptions.CurveEaseInOut, () =>
    {
        OrderProductsTableView.Frame = new CGRect(LeftPanel.Frame.Width + 130f, OrderProductsTableView.Frame.Location.Y, View.Frame.Size.Width - LeftAddProductPanel.Frame.Width, OrderProductsTableView.Frame.Size.Height);
        RightPanelFooter.Alpha = 0;
    }, null);

之后:

该按钮具有一个约束,因此它始终位于表格视图单元格(即xib)右侧的8 px英寸处

我想要/期望的是,随着tableview宽度的变化,按钮能够及时滑动。我是否错误地认为自动布局会解决这个问题


我可以在tableview上调用
reloadData()
,并在
cellforrowatinedexpath
中手动重新定位按钮,但希望有一种更优雅的方式。

您还需要设置按钮的动画。您可以通过以下方式获取对单元格的引用:

List<UITableViewCell> cells = OrderProductsTableView.VisibleCells.ToList();

然后还可以像之前一样设置表视图宽度的动画。动画应同时运行,并且按钮应随表视图宽度的动画一起移动

这是一个自动布局问题,请确保创建两个水平间距约束,一个是“大于或等于”>=您想要的最小宽度,另一个是“小于或等于”,这正是我最后要做的:)
UIView.Animate(0.05d, 0.15d, UIViewAnimationOptions.CurveEaseInOut, () =>
{
    foreach (UITableViewCell cell in cells)
    {
          MyCellType mCell = cell as MyCellType;
          mCell.trashButton.Frame = new CGRect(newXValue, newYValue, newWidthValue, newHeightValue);
    }

}, null);