gpt4 book ai didi

ios - 如何将UITableView单元格移到UITableView之外的另一个 View ?

转载 作者:行者123 更新时间:2023-12-01 16:30:11 25 4
gpt4 key购买 nike

我需要将UITableView单元格从tableview中移出,但是当我尝试将UITableViewCell移到它的tableview中时,我也需要在移动的同时进行动画处理。

这是我的代码:

   - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.

//config for HomeTableView
[HomeTableView setEditing:YES animated:YES];
[HomeTableView setScrollEnabled:YES];
[HomeTableView setAllowsSelection:YES];
[HomeTableView setAllowsSelectionDuringEditing:YES];

}

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath {
//i just change data source of my tableview at here

[self showViewGarbageAnimationMoveCell];//show custom view like garbage
//i want During when i move my cell if it is within bound of custom view -> it will be smaller scaled and be deleted when i end move on this cell.
//Unfortunately i can't move my cell to out of its tableview
}

-(void)showViewGarbageAnimationMoveCell
{
UIView * testView = [[UIView alloc] initWithFrame:CGRectMake(5.0f, 10.0f, 375.0f, 50.0f)];
[testView setBackgroundColor:[UIColor blueColor]];
[self.view addSubview:testView];

[UIView animateWithDuration:0.3f
delay:0.0f
options:UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse
animations:^{
[testView setFrame:CGRectMake(10.0f, 10.0f, 375.0f, 50.0f)];
}
completion:nil];
}

最佳答案

panGesture注册UITableViewCell,然后在调用panGesture的操作方法时进行处理,如下所示。

- (void)handelPanGesture:(UIPanGestureRecognizer* )panGesture
{
if (panGesture.state == UIGestureRecognizerStateBegan)
{
// save reference of start frame of tableViewCell
}
else if (panGesture.state == UIGestureRecognizerStateChanged)
{
// Check if panGesture.view is going out of UItablView bounds remove it from tableView add it to other View and set

}
else if (panGesture.state == UIGestureRecognizerStateEnded)
{
// if location is still in tableView set cell.Frame = back to startFrame
// if not arrange it to new view
}
}

关于ios - 如何将UITableView单元格移到UITableView之外的另一个 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32159796/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com