osx - When it's a right time to -expandItem: in a NSOutlineView? -
i have nsoutlineview use display items grouped sections.
┌──────────────────────────────┐ │ section 0 │ └──────────────────────────────┘ ┌────────────────────────────┐ │ item 0 │ └────────────────────────────┘ ┌────────────────────────────┐ │ item 1 │ └────────────────────────────┘ ┌──────────────────────────────┐ │ section 1 │ └──────────────────────────────┘ ┌────────────────────────────┐ │ item 2 │ └────────────────────────────┘
outline view backed custom fetched results controller issues 2 kinds of notifications on model changes:
- insert/move/delete section @ index (to index)
when notification insert/move/delete item @ root level of outline view. - insert/update/move/delete item @ index in section (to index in section)
when notification insert/update/move/delete item @ corresponding section level.
that is, manage outline view in incremental fashion , didn't make single -reloaddata call.
everything works expected. the sole problem need sections appear expanded.
unfortunately, nsoutlineview
api doesn't allow insert item in expanded state beginning. , there no obvious way customize behaviour via subclassing (i used hopper disassembler learn nsoutlineview internals, correct me if wrong).
my first attempt call -expanditem:
after insert section, doesn't have effect @ all.
the second attempt call -expanditem:
before add first nested item simulated section. has side effect of double insert.
the workaround found delay -expanditem:
call this:
id section = ... dispatch_async(dispatch_get_main_queue(), ^ { [self.outlineview expanditem: section]; });
this feels ugly , doesn't solve problem completely. example, more 1 section being added in 1 batch. item moves existing section new one, created , want row movement animation happen. instead corrupted nsoutlineview layout, section row gets clipped after section populated first time via -insertitemsatindexes:inparent:withanimation:
. run loop trick ruins everything.
so question is, when right time expand item, inserted via -insertitemsatindexes:inparent:withanimation:
?
Comments
Post a Comment