Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/108.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的底部。_Ios_Objective C_Uitableview - Fatal编程技术网

Ios 如何将UITableView单元格放到UITableView的底部。

Ios 如何将UITableView单元格放到UITableView的底部。,ios,objective-c,uitableview,Ios,Objective C,Uitableview,有20行UITableViewCell的UITableView,每行上都有一个按钮,单击按钮我想将UITableViewCell放到UITableView的底部 是否有任何委托方法可以执行此操作。 非常感谢您的反馈。是的,在tableview上有一个方法 - (void)moveRowAtIndexPath:(NSIndexPath*)indexPath                toIndexPath:(NSIndexPath*)newIndexPath 您可以阅读更多内容:是的,有一个

有20行UITableViewCell的UITableView,每行上都有一个按钮,单击按钮我想将UITableViewCell放到UITableView的底部

是否有任何委托方法可以执行此操作。
非常感谢您的反馈。

是的,在tableview上有一个方法

- (void)moveRowAtIndexPath:(NSIndexPath*)indexPath
               toIndexPath:(NSIndexPath*)newIndexPath
您可以阅读更多内容:

是的,有一个

为此,请使用以下委托方法:

必须返回
YES
以允许根据您的要求在
canmoverowatinexpath
delegate方法中移动tableView行

- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) // Don't move the first row
      return NO;

   return YES;
}
然后,使用
moveRowatineXpath
delegate方法相应地更新重新定位行的数据模型数组

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath 
      toIndexPath:(NSIndexPath *)toIndexPath 
{

      //Updating the data-model array
}
像按钮单击中的
moveRowAtIndexPath

- (void)btnClick:(UIButton*)sender
{
    UITableViewCell *cell = (UITableViewCell *)sender.superview;
    NSIndexPath *indexpath = [tableView indexPathForCell:cell];

    //Change accordindly as per requirement 
    [tableView moveRowAtIndexPath:[NSIndexPath indexPathForItem:indexpath.row inSection:indexpath.section] toIndexPath:[NSIndexPath indexPathForItem:0 inSection:indexpath.section]];

}
此外,请阅读苹果公司的相关文档:


你能用按钮动作显示你的代码吗