(Réglé) Warning lors de la suppression d'une cellule
Voila quand je souhaite supprimer une cellule de mon UITableView j'ai ce message qui s'affiche:
attempting to set a swipe to delete cell when we already have one....that doesn't seem good
Voila mon code:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title=@Vos favoris;
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
listOffer.delegate=self;
listOffer.dataSource=self;
listOffer.editing=true;
listOffer.allowsSelectionDuringEditing=true;
}
- (void) reloadDateFromTable:(NSMutableArray*) reloadArray{
_liste=reloadArray;
[listOffer performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 100;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 20;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
DetailViewController* detail = [[DetailViewController alloc]init];
[self.navigationController pushViewController:detail animated:NO];
}
#define kBgQueue dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
static NSString* const UCellIdentifier = @CelluleOffre;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
CelluleOffre* cell = (CelluleOffre *)[tableView dequeueReusableCellWithIdentifier:UCellIdentifier];
if(cell==nil){
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:UCellIdentifier owner:nil options:nil];
cell = [nib objectAtIndex:0];
}
return cell;
}
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 0)
{
return NO;
}
return YES;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if(editingStyle == UITableViewCellEditingStyleDelete)
{
[_liste removeObjectAtIndex:indexPath.row];
[listOffer reloadData];
}
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:NO];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:NO animated:NO];
}
Merci d'avance à ceux qui m'aideront
Connectez-vous ou Inscrivez-vous pour répondre.
Réponses
http://stackoverflow.com/questions/22425706/ios-7-uitableview-issue-attempting-to-set-a-swipe-to-delete-cell-when-we-alrea ?
Hello Larme,
J'ai effectivement vu ce sujet, et j'ai testé le code donné par Gman
Seulement ça me fait une erreur
Bon j'ai rien dit désolé
ça te semble normal d'avoir un MagicNumber et de ne pas faire ça de manière dynamique en comptant le nombre d'objets de ton DataSource?
C'est dans le cadre d'un test, sinon effectivement il y a un liste.count