nstableview reload with animation possible?

  • Hi,

    What I'm basically trying to do is call reloadData but with animation and I can't see how to do it?  I know about removing/inserting rows with animation and I tried this, but I keep crashing and I would think it's because I'm removing rows and inserting rows after my datasource has been modified.  That's why normally I use reloadData and it works fine.  Also, it seems there is a method to do this in iOS but it's not available on Mac.  So is it possible to do this?  Or can I only use the animation when removing inserting rows without changing the modifying the datasource?  Thanks,

    rc
  • > What I'm basically trying to do is call reloadData but with animation and I can't see how to do it?  I know about removing/inserting rows with animation and I tried this, but I keep crashing and I would think it's because I'm removing rows and inserting rows after my datasource has been modified.  That's why normally I use reloadData and it works fine.  Also, it seems there is a method to do this in iOS but it's not available on Mac.  So is it possible to do this?  Or can I only use the animation when removing inserting rows without changing the modifying the datasource?  Thanks,
    >
    Hi Rick,

    You probably want
    - (void)reloadDataForRowIndexes:(NSIndexSet *)rowIndexes columnIndexes:(NSIndexSet *)columnIndexes NS_AVAILABLE_MAC(10_6);

    In my app, I use it to update rows which get updated one at a time but you can provide an index set with many rows. You might be able to use -rowsInRect which I haven't used passing the rect of the table view's scroll view, I would think. Then you can create the index set with -indexSetWithIndexesInRange:

    Hope this helps
    Marc
  • Thanks I will take a look!

    On Jun 19, 2012, at 3:59 AM, Marc Respass wrote:

    >> What I'm basically trying to do is call reloadData but with animation and I can't see how to do it?  I know about removing/inserting rows with animation and I tried this, but I keep crashing and I would think it's because I'm removing rows and inserting rows after my datasource has been modified.  That's why normally I use reloadData and it works fine.  Also, it seems there is a method to do this in iOS but it's not available on Mac.  So is it possible to do this?  Or can I only use the animation when removing inserting rows without changing the modifying the datasource?  Thanks,
    >>
    > Hi Rick,
    >
    > You probably want
    > - (void)reloadDataForRowIndexes:(NSIndexSet *)rowIndexes columnIndexes:(NSIndexSet *)columnIndexes NS_AVAILABLE_MAC(10_6);
    >
    > In my app, I use it to update rows which get updated one at a time but you can provide an index set with many rows. You might be able to use -rowsInRect which I haven't used passing the rect of the table view's scroll view, I would think. Then you can create the index set with -indexSetWithIndexesInRange:
    >
    > Hope this helps
    > Marc
  • Well, that method doesn't animate.

    Conceptually, what you have to do is this (and assuming you are using a view based table view):

    1. Call beginUpdates on the table *important*
    2. Modify the table to add/remove all the rows that you added or removed. Note that it works like an NSArray, so calling removeRow:3 will remove row 3, and then what was at row 4 is now at row 3. So to delete what was at row 4 you call removeRow:3 again. This is *different* from how it works on iOS which "freezes" the table and does not treat it like an array
    3. Call endUpdates

    The table will not call the datasource during the time you call beginUpdates/endUpdates.

    corbin

    On Jun 18, 2012, at 5:26 PM, Rick C. <rickcorteza...> wrote:

    > Thanks I will take a look!
    >
    >
    > On Jun 19, 2012, at 3:59 AM, Marc Respass wrote:
    >
    >>> What I'm basically trying to do is call reloadData but with animation and I can't see how to do it?  I know about removing/inserting rows with animation and I tried this, but I keep crashing and I would think it's because I'm removing rows and inserting rows after my datasource has been modified.  That's why normally I use reloadData and it works fine.  Also, it seems there is a method to do this in iOS but it's not available on Mac.  So is it possible to do this?  Or can I only use the animation when removing inserting rows without changing the modifying the datasource?  Thanks,
    >>>
    >> Hi Rick,
    >>
    >> You probably want
    >> - (void)reloadDataForRowIndexes:(NSIndexSet *)rowIndexes columnIndexes:(NSIndexSet *)columnIndexes NS_AVAILABLE_MAC(10_6);
    >>
    >> In my app, I use it to update rows which get updated one at a time but you can provide an index set with many rows. You might be able to use -rowsInRect which I haven't used passing the rect of the table view's scroll view, I would think. Then you can create the index set with -indexSetWithIndexesInRange:
    >>
    >> Hope this helps
    >> Marc

  • Thanks again for the replies.  Think I was able to get it to work just had to re-code a few things compared to simply using reloadData...

    rc

    On Jun 20, 2012, at 1:58 AM, Corbin Dunn wrote:

    > Well, that method doesn't animate.
    >
    > Conceptually, what you have to do is this (and assuming you are using a view based table view):
    >
    > 1. Call beginUpdates on the table *important*
    > 2. Modify the table to add/remove all the rows that you added or removed. Note that it works like an NSArray, so calling removeRow:3 will remove row 3, and then what was at row 4 is now at row 3. So to delete what was at row 4 you call removeRow:3 again. This is *different* from how it works on iOS which "freezes" the table and does not treat it like an array
    > 3. Call endUpdates
    >
    > The table will not call the datasource during the time you call beginUpdates/endUpdates.
    >
    > corbin
    >
    > On Jun 18, 2012, at 5:26 PM, Rick C. <rickcorteza...> wrote:
    >
    >> Thanks I will take a look!
    >>
    >>
    >> On Jun 19, 2012, at 3:59 AM, Marc Respass wrote:
    >>
    >>>> What I'm basically trying to do is call reloadData but with animation and I can't see how to do it?  I know about removing/inserting rows with animation and I tried this, but I keep crashing and I would think it's because I'm removing rows and inserting rows after my datasource has been modified.  That's why normally I use reloadData and it works fine.  Also, it seems there is a method to do this in iOS but it's not available on Mac.  So is it possible to do this?  Or can I only use the animation when removing inserting rows without changing the modifying the datasource?  Thanks,
    >>>>
    >>> Hi Rick,
    >>>
    >>> You probably want
    >>> - (void)reloadDataForRowIndexes:(NSIndexSet *)rowIndexes columnIndexes:(NSIndexSet *)columnIndexes NS_AVAILABLE_MAC(10_6);
    >>>
    >>> In my app, I use it to update rows which get updated one at a time but you can provide an index set with many rows. You might be able to use -rowsInRect which I haven't used passing the rect of the table view's scroll view, I would think. Then you can create the index set with -indexSetWithIndexesInRange:
    >>>
    >>> Hope this helps
    >>> Marc

    >
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