Ich habe einen TableView. Wenn ich auf die Zelle klicke, wird die Datei mit der Animation UIActivityIndicator
heruntergeladen. Sobald der Download abgeschlossen ist, wird das Häkchen angezeigt (die Datei existiert) und der Benutzer kann zum nächsten Controller wechseln. Nach dem Wechsel zum nächsten Controller und Zurückkehren sind alle Häkchen verschwunden. Wie es geht?Häkchen entfernen
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: [NSString stringWithFormat:@"Cell%d", indexPath.row] forIndexPath:indexPath];
if (indexPath.row == 1){
if (!fileExists) {
[_spinner startAnimating];
}
if (fileExists) {
cell.accessoryView = nil;
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
}
if (indexPath.row == 2){
if (!fileExists1) {
[_spinner1 startAnimating];
}
if (fileExists1) {
cell.accessoryView = nil;
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 1) {
if (!fileExists) {
_spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
_spinner.frame = CGRectMake(0, 0, 24, 24);
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.accessoryView = _spinner;
tableView cellForRowAtIndexPath:indexPath].accessoryView = _spinner;
[_spinner startAnimating];
if (fileExists) {
[tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark;
}
}
}
}
Können Sie bitte weiteren Code wie 'cellForRowAtindexPath' und' didSelectRowAtIndexPath' hinzufügen. –
@Benutzer überprüfen Sie die Antwort, war dies Ihre Anforderung? – aircraft
@NiravD Ich aktualisiere meine Frage. Bitte prüfe. – user