Is anybody having luck getting tables to animate properly for editing? I know there were redraw issues with cell addition and deletion in previous betas, but b6 seems to have improved these issues. However, I'm getting bit by something else and I'm not sure if it's my doing or if it's another SDK bug.
I'm going for something similar to the contact editing interface where, in edit mode, new sections appear with a with an "Add new blahblah" cell. It looks like I've got entering edit mode working, but I'm having trouble with exiting edit mode.
Whenever I remove what was previously the final section of the table, I see the following lines in my console:
Fri May 30 17:47:08 esb-pro-2.local app[5807] <Error>: CGImageCreate: invalid image size: 18 x 0.
Fri May 30 17:47:08 esb-pro-2.local app[5807] <Error>: CGImageCreate: invalid image size: 18 x 0.
Eventually, if I toggle in and out of edit mode long enough, the app crashes when it's trying to dealloc a UIImage, so I'm guessing the two are related.
I've tried removing the one-cell editing section both by removing the individual row and removing the whole section - both have the same problem.
I'm curious if anybody has tried something similar or has seen anything like this.
I am doing it without any trouble. Are you using insertSections:withRowAnimations:/deleteSections:withRowAnimations:?
The only thing I had trouble with was figuring out what to pass it for the NSIndexSet values because the documentation was very vague in that area. I had all kinds of issues until I realized I was doing that wrong and it works fine now. Feel free to share some code and I can take a look.
Yeah, I'm using insertSections:withRowAnimations:/deleteSections:withRowAnimations:
I'm reworking from scratch to see if I can figure out where the problem's coming from. It's tedious, but I'd have to do the same thing separate out the code enough to share. Haven't seen any breakage yet, so maybe I'll get lucky in my restructuring.
I am getting strange behavior also, I just didn't realize it earlier. I keep getting the following error when I try to insert rows in a newly created section I add between two other sections (there are a total of 3 including this one, it is going in the middle of the two). If I just add the section (and not the rows)it works fine, but the cells that were already on the screen don't update. When I add the line to insert the rows I get the error. The thing is it starts with one section and you can add the last two in either order, but they always have the same index when added. If I use this same code when I only have one section and add it to the end it works. I can even add the third section after it after that without problems. It seems to be happening after committing all the row changes in my code while the tableView is doing it's thing. Seems like there could be an issue with TableViews, but I never added rows like this before beta 6 so I could be doing something wrong. I have looked over my code for the last 3 hours piecing it apart though, and I am starting to think it could be that tableView has some issues.
Well, it looks like my problems are related to the index when both removing sections and rows (from sections that aren't being removed). Plus, it looks like it's not the last row that's causing problems, but the first one (under certain circumstances).
I basically started over with a sample case that displays any phone numbers, email addresses, and urls for a contact. When you enter edit mode, any sections containing data have an "Add..." button added to the end of the section. Any sections without data (and therefore, not displayed) are added with a single "Add..." row.
If I display a contact with no phone number, but some combination of emails addresses and urls, I get the error I mentioned earlier and the eventual crash. If I display a contact with none of this data, it works fine. If I display a contact with a phone number and some other data, it works fine.
I've been assuming that the insert indexes in this case would be the same as the removal indexes, but this behavior is making me question that assumption. I just have no idea how what the appropriate configuration would be - it took me most of a day to get the the point where I had the proper setup to enter edit mode.
Here's the setEditing function, where I figure out the indixes - I go through each potential section, determine whether it's present, and try to make the appropriate modification to the table.
If I display a contact with no phone number, but some combination of emails addresses and urls, I get the error I mentioned earlier and the eventual crash. If I display a contact with none of this data, it works fine. If I display a contact with a phone number and some other data, it works fine.
So if there is no phone number you are adding the phone number section above the email/url sections when editing? If so that is the same thing I am doing that is causing problems.
Yeah, that about sums up what I'm doing. My problems come when I both add the extra section and add the extra row to the existing section.
Are you making the same assumption about the indixes that I'm making - ie, the insertion and removal indices are the same? I'm leaning towards logging a bug with Apple for this. At least if I'm wrong, maybe they'll point me in the right direction.
I'm now really confident this is an Apple bug - if I switch from a grouped table style to a plain table style, I don't get the error messages in the console.
Are you still using section titles/headers in the plain view?
No - I just switched the from specifying UITableViewStyleGrouped to UITableViewStylePlain to get another data point. I didn't bother setting up table sections. My goal is to switch back to the grouped style at a later point.
The plain view isn't perfect though - I've noticed a situation where sometimes a section will get duplicated when I switch into editing mode, regardless of the table style. After toggling in and out of edit mode, I'll eventually see a crash.
I am still having tons of trouble with this and can't figure it out. I gave up on doing it in the previous table mentioned in this thread and this is a totally different table with different data and at this point I am almost certain that it is a bug. Has anyone had much luck with removing table sections with headers in the plain style? I have a log style table with rows for certain days that entries are made with section headers dividing it into months. If there are no entries for am month I don't show a header for it. If a row is deleted and it is the last row in the section I also want to delete the section. Every once in awhile the section disappears properly but usually the section header that should have been removed moves down and obscures view of part of the section below. I am even calling reloadData and verifying that my data source is updating, but the graphics are still messed up. If I quit the program and come back in it reloads all the data from the sql db and appears properly with the deleted section header no long obscuring part of the section below.
Also I have found that if I use a if/else like this I won't see any problems but suddenly certain rows stop recieving touches mysteriously like maybe something invisible is over them keeping them from recieving touches.
I can also confirm that it is working perfectly without the above code. I commented it out and called reloadData instead, it isn't animated, but the table updates as expected so it doesn't seem to be my data.
In case anyone else is having trouble with it this is what I did. It isn't documented, but in response to my ticket the engineers told me to remove just the section and not the row when deleting the last row in a section. This works perfectly starting with Beta 7, but not in 6.