J'ai une sous-classe de UITableViewCell
appelée ReminderCell
.Cellule personnalisée de retour de UITableViewCell
ReminderCell
a une méthode appelée backToPlaceAnimation
que j'ai écrite.
Le problème est par exemple si je veux appeler backToPlaceAnimation
le premier ReminderCell
de RemindersVC
en utilisant tableView: cellForRowAtIndexPath:
il ne revient pas l'objet correct (il est l'objet UITableViewCell
et non ReminderCell
du tout).
Comment puis-je obtenir l'objet correct?
code:
NSIndexPath *cellIndexPath=[NSIndexPath indexPathWithIndex:0];
ReminderCell *cell=(ReminderCell*)[self tableView:self.AroundersTableView cellForRowAtIndexPath:cellIndexPath];
[cell cancelDeletion];
journal Crash:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid index path for use with UITableView. Index paths passed to table view must contain exactly two indices specifying the section and row. Please use the category on NSIndexPath in UITableView.h if possible.
cellForRowAtIndexPath: override:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//Creating a default cell using "cellIdentifier"(NSString)
ReminderCell *cell=[tableView dequeueReusableCellWithIdentifier:@"Cell"];
if (cell==nil) {
cell=[[ReminderCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
}
//Changing "cell"'s "index" to indexPath.row
cell.index=(int)indexPath.row; //Crashes here
[email protected]"Hello";
//Returning cell
return cell;
}
Merci!
Afficher un code sur la façon dont vous obtenez les cellules de 'cellForRowAtIndexPath' –
Êtes-vous. –
@DantePuglisi Mis à jour le message, s'il vous plaît jeter un oeil –