gpt4 book ai didi

ios - 编辑 UITableViewCell 时将 UIActivityIndi​​cator 放在单元格中并禁用 UserInteraction

转载 作者:行者123 更新时间:2023-11-29 12:26:49 27 4
gpt4 key购买 nike

当用户单击 UITableView 中的删除按钮时(编辑打开时),UIActivityIndi​​cator 会显示在 tableView 的中间,因为我想不出一种方法将它放在要删除的 Cell 的中间.这是我现在正在使用的代码:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {

self.activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
//cell.accessoryView = self.activityView;


self.activityView.center = self.tableView.center;
[self.tableView addSubview:self.activityView];

[self.activityView startAnimating];
.... rest of the code

所以 1)

第一个问题如何把indicatorView放在被删除的cell中间。

2) 发生这种情况时是否可以禁用删除按钮?我不希望用户大量单击按钮。

编辑1

我忘了提到我正在为电池 socket 使用自定义类。因此,在您要填充的普通 tableView 中,我使用此代码获取每个单元格

GamesInfoTableViewCell *cell1 = (GamesInfoTableViewCell *)[tableView dequeueReusableCellWithIdentifier:otherSection];

最佳答案

试试这段代码。它会将 subview 添加到您要删除的单元格的中心。

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {

spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];

UITableViewCell * cell = [tableView cellForRowAtIndexPath: indexPath];
// Setting Frame of Spinner..
CGFloat x = (cell.frame.size.width-spinner.frame.size.width)/2;
CGFloat y = (cell.frame.size.height-spinner.frame.size.height)/2;

spinner.frame = CGRectMake(x, y, spinner.frame.size.width, spinner.frame.size.height);

[cell addSubview: spinner];

[spinner startAnimating];
//Do YOUR WORK NOW
}
}

快乐编码..:)

关于ios - 编辑 UITableViewCell 时将 UIActivityIndi​​cator 放在单元格中并禁用 UserInteraction,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28828539/

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