gpt4 book ai didi

iphone - 更改 UITableViewCell 附件后 UITableViewCellAccessoryDe​​tailDisclosureButton 消失

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

我有一个 UITableView,其中包含带有图像、文本和披露按钮的单元格。我正在像这样加载单元格:

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
static NSString *cellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if(!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
}

if ([indexPath row] == [[self multas] count]) {
[[cell textLabel] setText:@"Carregar mais..."];
}
else
{
Multa *multa = [self.multas objectAtIndex:indexPath.row];

NSString *dataIsolada = [[NSString stringWithFormat:[multa dataOcorrencia]] substringWithRange:NSMakeRange(0, 10)];

[[cell textLabel] setText:[NSString stringWithFormat:dataIsolada]];
[[cell detailTextLabel] setText:[multa descricao]];
[cell.imageView setImageWithURL:[NSURL URLWithString:[multa fotoURL]]
placeholderImage:[UIImage imageNamed:@"carregando.jpeg"]];
[cell.imageView setContentMode: UIViewContentModeScaleAspectFit];
[cell setAccessoryType:UITableViewCellAccessoryDetailDisclosureButton];
}

return cell;
}

当用户点击显示按钮时,我将显示按钮切换为 Activity Indicator,然后使用导航 Controller 将另一个 View 推送到屏幕:

- (void)carregarDetalhesMulta:(UITableView *)tableView comMulta:(Multa *)multa 
{
DetalheMultaViewController *form = [[DetalheMultaViewController alloc] initWithMulta:multa];
form.delegate = self;

UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:form];

[self presentModalViewController:navigation animated:YES];
}

- (void) tableView: (UITableView *) tableView accessoryButtonTappedForRowWithIndexPath: (NSIndexPath *) indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle: UIActivityIndicatorViewStyleGray];
spinner.frame = CGRectMake(0, 0, 24, 24);
cell.accessoryView = spinner;
[spinner startAnimating];

Multa *multa = [self.multas objectAtIndex:indexPath.row];

double delayInSeconds = 0.1;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);

dispatch_after(popTime, dispatch_get_main_queue(), ^(void){

[spinner stopAnimating];
[self carregarDetalhesMulta:tableView comMulta:multa];
[cell setAccessoryType:UITableViewCellAccessoryDetailDisclosureButton];
});

}

请注意,最后我已将披露按钮的配件改回。问题是:当我返回(通过点击返回按钮)到包含 UITableView 的 View 时,我点击的行没有显示披露按钮或事件指示器。我做错了什么?无需重新加载表格 View 即可切换这些控件的更好方法是什么?

最佳答案

accessoryView 属性优先于 accessoryType 属性。如果将 accessoryView 设置为 nil,您将再次看到附件按钮。

关于iphone - 更改 UITableViewCell 附件后 UITableViewCellAccessoryDe​​tailDisclosureButton 消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15754240/

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