last day (14 days later) » 

12:13 PM
0
A: In an iOS table view, how should a row be moved to a new section?

fluidsonicUse -[UITableView moveRowAtIndexPath:toIndexPath:]

 
I tried that. I also tried inserting the section then moving the row. Both produce exceptions.
If you just do move, you get: Invalid update: invalid number of sections. The number of sections contained in the table view after the update (2) must be equal to the number of sections contained in the table view before the update (1), plus or minus the number of sections inserted or deleted (0 inserted, 0 deleted).
If you insert the section then move, you get: cannot move a row into a newly inserted section (1)
 
You must make sure that at the point you call endUpdates the methods numberOfSectionsInTableView: and tableView:numberOfRowsInSection: must correctly reflect the new values.
 
Yes, those methods return the correct values. The error message states the problem is the sections have not been inserted or deleted. If I insert them, it has already loaded the row. The problem is, because the new row is the same object as the row that has been removed from another section, it fails to render it correctly. I think the only solution to this would be a table reload.
 
Ah I see your new problem. You could always use two sections even if section 1 is empty at first. Then you can just animate the row into the empty section since you don't need to create it anymore.
 
I just didn't want a header there with nothing under it...
 
12:13 PM
You can return nil for headerForSection to control that.
 
If I return nil for titleForHeaderInSection then it doesn't display the header, so moving the cell works then. However, there is a rendering issue with the header as it displays in the wrong place with no background before rendering again some time after.
 
What if you display the header all the time but initially with height 0?
Also make sure the header has clipsToBounds set to YES for that to work.
 
12:29 PM
I'm not making a custom header though, so I don't have the header view object
What would I return if I didn't want the header to be 0 height? super returns 0.
 
hmm, other's suggest not using 0 but 0.0001f
 
Ok, if I return a UITableViewHeaderFooterView with the header text on it, clips to bounds YES, it still doesn't render when displaying the header
not displayed height as 0.1f
renders about 1s later
it just doesn't re-render the header when it's height has changed, annoying!
 
12:48 PM
I just tried it in a new project and it works fine.
ah wait
oh yeah, the header is slightly off
 
I don't think Apple intended it to be done this way...I don't know what way they did intend it to be done though
It might all stem from the fact I'm using the same object when moving a cell to a new section
I think they expect you to dequeue
 
No I think it's a bug. There's nothing wrong about changing multiple things at once.
If you do't need the header stick to the top you could also use a cell at position 0 of section 1 which just looks like the header.
 
Yeah, I've reported a similar bug before about rendering in table view. It's still not fixed.
 
They're really slow about fixing bugs :(
I started my own list view implementation but it's way more work than I expected.
Table view must be unbelievable complex.
 
I bet. Especially if you have many rows
 
12:55 PM
I'm also working on an issue related to begin/endUpdates and delete/insert/move
The order you have to do all that stuff is barely documented.
 
Yup! You'd think it would be better having been there since day 1
Anyway, thanks for the help. I'll report what I've tried as a bug report. I'm just going to reload the table. No point wasting more time just to get a bit of animation. Cheers
 
you're welcome
 
 
2 hours later…
2:58 PM
Bug opened as rdar://18622906
 

last day (14 days later) »