nstableview remove/insert rows question

  • Hi,

    Got a view-based table view and instead of using reloadData I'm removing the existing rows and inserting the new rows so that I can have animation.  I'm also resizing the window in-between these 2 steps because my window resizes to fit how many rows are in my table view.  This works great when my window doesn't resize (due to same amount of rows) or resizes very little.  However let's say I have only 2 rows then remove those 2 rows and resize the window (using setFrame:display:animate:) and finally insert a much larger amount of rows like 15 what happens is the top 5 or 6 rows animate as expected but the rows further down just appear as if I was calling reloadData.  I have checked this and reloadData is not being called, but I can't figure out why all rows don't animate.  Any ideas?

    Thanks,

    rc
  • On Jun 28, 2012, at 4:30 AM, Rick C. <rickcorteza...> wrote:

    > Hi,
    >
    > Got a view-based table view and instead of using reloadData I'm removing the existing rows and inserting the new rows so that I can have animation.  I'm also resizing the window in-between these 2 steps because my window resizes to fit how many rows are in my table view.  This works great when my window doesn't resize (due to same amount of rows) or resizes very little.  However let's say I have only 2 rows then remove those 2 rows and resize the window (using setFrame:display:animate:) and finally insert a much larger amount of rows like 15 what happens is the top 5 or 6 rows animate as expected but the rows further down just appear as if I was calling reloadData.  I have checked this and reloadData is not being called, but I can't figure out why all rows don't animate.  Any ideas?

    Yes -- I have ideas; actually, even better, I know what is happening! The table is very efficient at bringing in only the views you need. What's happening here is your animation insert or delete is happening, and no other views are visible (or need to be). Then, the table is resized via the window animation, exposing more rows that didn't participate in the animation. You can trick them to participate in the animation by pulling them in before doing the animation; if you are going to have X rows be revealed, call rowViewAtRow:makeIfNecessary:YES for the X rows past the last visible one first.

    corbin

    >
    > Thanks,
    >
    > rc
  • Great I will check this out thanks Corbin!

    rc

    On Jun 29, 2012, at 4:26 AM, Corbin Dunn wrote:

    >
    > On Jun 28, 2012, at 4:30 AM, Rick C. <rickcorteza...> wrote:
    >
    >> Hi,
    >>
    >> Got a view-based table view and instead of using reloadData I'm removing the existing rows and inserting the new rows so that I can have animation.  I'm also resizing the window in-between these 2 steps because my window resizes to fit how many rows are in my table view.  This works great when my window doesn't resize (due to same amount of rows) or resizes very little.  However let's say I have only 2 rows then remove those 2 rows and resize the window (using setFrame:display:animate:) and finally insert a much larger amount of rows like 15 what happens is the top 5 or 6 rows animate as expected but the rows further down just appear as if I was calling reloadData.  I have checked this and reloadData is not being called, but I can't figure out why all rows don't animate.  Any ideas?
    >
    > Yes -- I have ideas; actually, even better, I know what is happening! The table is very efficient at bringing in only the views you need. What's happening here is your animation insert or delete is happening, and no other views are visible (or need to be). Then, the table is resized via the window animation, exposing more rows that didn't participate in the animation. You can trick them to participate in the animation by pulling them in before doing the animation; if you are going to have X rows be revealed, call rowViewAtRow:makeIfNecessary:YES for the X rows past the last visible one first.
    >
    > corbin
    >
    >>
    >> Thanks,
    >>
    >> rc
    >
  • Unfortunately Corbin I'm not sure I'm following here.  So I remove my old rows sliding left and then resize my window and at that point I currently have no rows (my datasource has been updated though).  So if I try to call rowViewAtRow: I get an exception since I have no rows.  I can go ahead and insert my new rows (sliding in from the right) and it works, except for what I explained before that if the jump is very big in number of rows not all of them will slide in from the right some will just appear.  There must be something I'm misunderstanding?

    rc

    On Jun 29, 2012, at 4:26 AM, Corbin Dunn wrote:

    >
    > On Jun 28, 2012, at 4:30 AM, Rick C. <rickcorteza...> wrote:
    >
    >> Hi,
    >>
    >> Got a view-based table view and instead of using reloadData I'm removing the existing rows and inserting the new rows so that I can have animation.  I'm also resizing the window in-between these 2 steps because my window resizes to fit how many rows are in my table view.  This works great when my window doesn't resize (due to same amount of rows) or resizes very little.  However let's say I have only 2 rows then remove those 2 rows and resize the window (using setFrame:display:animate:) and finally insert a much larger amount of rows like 15 what happens is the top 5 or 6 rows animate as expected but the rows further down just appear as if I was calling reloadData.  I have checked this and reloadData is not being called, but I can't figure out why all rows don't animate.  Any ideas?
    >
    > Yes -- I have ideas; actually, even better, I know what is happening! The table is very efficient at bringing in only the views you need. What's happening here is your animation insert or delete is happening, and no other views are visible (or need to be). Then, the table is resized via the window animation, exposing more rows that didn't participate in the animation. You can trick them to participate in the animation by pulling them in before doing the animation; if you are going to have X rows be revealed, call rowViewAtRow:makeIfNecessary:YES for the X rows past the last visible one first.
    >
    > corbin
    >
    >>
    >> Thanks,
    >>
    >> rc
    >
  • Hi everyone,

    Can I bump this because I'm still stuck here. :-)  And maybe I can ask in a new way here's what I'm trying to do:

    1.  Remove old rows from tableview (let's say 5) with sliding left animation
    2.  Update array being used as datasource (let's say now it contains 15 items)
    3.  Resize my window containing my table view to fit the amount of rows (setFrame:display:animate)
    4.  Insert my new rows (all 15 of them) with sliding right animation

    Problem is between steps 3 and 4 I think the the window resizing is not finished before the inserting rows step comes.  So the last couple of rows do not insert with animation but they just appear as reloadData would normally do.  This does not happen if the difference is rows is 0 or minimal.  But in my example (from 5 to 15) it will happen.  And sorry but I couldn't figure out how to use rowViewAtRow in this situation it always throws an exception.  Any help would be much appreciated thanks!

    rc

    On Jun 29, 2012, at 4:26 AM, Corbin Dunn wrote:

    >
    > On Jun 28, 2012, at 4:30 AM, Rick C. <rickcorteza...> wrote:
    >
    >> Hi,
    >>
    >> Got a view-based table view and instead of using reloadData I'm removing the existing rows and inserting the new rows so that I can have animation.  I'm also resizing the window in-between these 2 steps because my window resizes to fit how many rows are in my table view.  This works great when my window doesn't resize (due to same amount of rows) or resizes very little.  However let's say I have only 2 rows then remove those 2 rows and resize the window (using setFrame:display:animate:) and finally insert a much larger amount of rows like 15 what happens is the top 5 or 6 rows animate as expected but the rows further down just appear as if I was calling reloadData.  I have checked this and reloadData is not being called, but I can't figure out why all rows don't animate.  Any ideas?
    >
    > Yes -- I have ideas; actually, even better, I know what is happening! The table is very efficient at bringing in only the views you need. What's happening here is your animation insert or delete is happening, and no other views are visible (or need to be). Then, the table is resized via the window animation, exposing more rows that didn't participate in the animation. You can trick them to participate in the animation by pulling them in before doing the animation; if you are going to have X rows be revealed, call rowViewAtRow:makeIfNecessary:YES for the X rows past the last visible one first.
    >
    > corbin
    >
    >>
    >> Thanks,
    >>
    >> rc
    >
previous month june 2012 next month
MTWTFSS
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30  
Go to today