Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

Problem removing cells from tableview

japsjaps Posts: 29Registered Users
I´m having a problem when trying to delete the right row in my tableview. I have 3 dynamic created cells grouped, and also, i´m using the editing mode. Everything is working fine when adding more rows in each section, but when i try to delete a specific row in a specific section, it does´t work correctly. Let´s say that i have added rows 1,2,3 (besides de original one) and i want to delete number 2, it works for the first time, but then it gets stuck!!. I have also a method that gives automatically a tag for each new row created.
I think my problem is that the row.tag in the tableview are not matching with the ones in my array(i have an array receiving the inserted cells, and it should work with the deleted ones!!!). Here is my code:


- (void)tableView:(UITableView *)TableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath
{

if (editingStyle == UITableViewCellEditingStyleDelete)
{

int i=0;
for (i=0; i<myarray.count; i++)
{
UITableViewCell *aux=[myarray objectAtIndex:i];
UITableViewCell* myCell = (UITableViewCell *)[(UITableView *)TableView cellForRowAtIndexPath:indexPath];

if (aux.tag == myCell.tag)
{
[TableView beginUpdates];
[myarray removeObjectAtIndex:i];
[TableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]withRowAnimation:UITableViewRowAnimationFade];
[TableView endUpdates];

What am i doing wrong? how can i match the deleted rows in the tableview and in the array at the same time?

Thanks
Post edited by japs on

Replies

Sign In or Register to comment.