[Uiimageview Setto:]: Selettore non riconosciuto inviato all'istanza
-
13-12-2019 - |
Domanda
Mi dispiace se è già stato chiesto, ma qui viene il problema:
Io ricevo questo messaggio quando scorrò velocemente il tableview:
APP di terminazione a causa dell'accezione non rilevata 'NsinValidargumentExcetion', Motivo: '- [UIIMAGEView Setto:]: Selettore non riconosciuto inviato all'istanza 0x8a8f8d0'
Ecco il mio codice:
NewsVideoCell *cell = [tableView dequeueReusableCellWithIdentifier:AudioCellIdentifier];
if (cell == nil) {
cell = [[NewsVideoCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:AudioCellIdentifier];
}
cell.backgroundView = [ [UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"news_bg"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 0, 10, 0)] ];
cell.selectedBackgroundView = [ [UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"news_bg"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 0, 10, 0)] ];
UILabel *cellLabel = (UILabel *)[cell viewWithTag:1];
[cellLabel setText:[masjid objectForKey:@"name"]];
UILabel *cellDate = (UILabel *)[cell viewWithTag:2];
[cellDate setText:[[news objectAtIndex:indexPath.row] objectForKey:@"date"]];
UIImageView *cellImage = (UIImageView *)[cell viewWithTag:3];
NSString *imagePath = [masjid objectForKey:@"thumb"];
[cellImage setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@", imagePath]]];
UITextView *cellText = (UITextView *)[cell viewWithTag:5];
NSString *postText = [[news objectAtIndex:indexPath.row] objectForKey:@"title"];
[cellText setText:postText];
...
.
E la linea che spara questa eccezione è:
[cellText setText:postText];
.
Ho visto che è dovuto a un sovra-ritenente o sotto-rilascio, ma non trovo un modo per risolverlo.
Qualsiasi aiuto PLZ?
Soluzione
UITextView *cellText = (UITextView *)[cell viewWithTag:5];
.
In questa riga di codice il tuo tag per uitextview è "5", penso che potresti aver dato un ID diffrent per questa visione.Prima.
Ho avuto problemi Similler .... Ho trovato che il mio tag è stato diffrent per TextView e View Image.
.Come cambiare il tag per una vista?
.PRIMA Seleziona la vista (ad esempio UitextView) e che andare su Attribute Inspector TAB ..... sotto la "vista" troverai 'tag' scrivi lì 5.
Spero che potrebbe essere utile per te.
Altri suggerimenti
setText
è un metodo UITextView
non UIImageView
.Ora come menzionato nel commento, il testo celltext non è un'istanza UITextView
, sembra essere un'istanza UIImageView
, quindi si tenta di chiamare il metodo setText
da un'istanza UIImageView
che causano l'arresto anomalo dell'app.Prova a testarlo per assicurarti:
UITextView *cellText = (UITextView *)[cell viewWithTag:5];
if([cellText class] != [UITextView class]){
cellText = [[UITextView alloc]init];
}
NSString *postText = [[news objectAtIndex:indexPath.row] objectForKey:@"title"];
[cellText setText:postText];
.
In questo modo, se cellText
non è un'istanza UITextView
, avrà una per te.