21 Commits

Author SHA1 Message Date
Li Tan
3e6436245d fix inserting sections bug 2014-12-18 13:07:43 -08:00
Nadine Salter
89a0a25347 Remove CATransaction hack.
ASRangeController previously enqueued display of individual nodes by
adding their views to the hierarchy, wrapping each `-addSubview:` call
in an explicit CATransaction to force displays to occur in order.  This
hack is no longer necessary -- kill it.
2014-12-16 14:10:04 -08:00
Li Tan
62248ee0eb Fix crash in reloadData 2014-12-15 22:36:57 -08:00
Li Tan
f7f5988fcd Support editing in table view and collection view 2014-12-15 13:19:10 -08:00
越凡
263db6f46c When doing refresh, we should cancel perform requests previously registered with performSelector:withObject:afterDelay: first, or it will do the sizeNextBlock twice with the same indexPath and then it will crash. 2014-12-07 14:26:09 +08:00
Ryan Nystrom
36cbea4f8f Update manual display logic
Postpone manual display until a future release when it can be called on any thread. Provide the current node manual display logic as a category on ASDisplayNode only available for ASRangeController. Deprecate -displayImmediately.
2014-12-04 11:55:17 -08:00
Nadine Salter
1103f82a5c .preventOrCancelDisplay -> .displaySuspended.
Rename the ASDisplayNode property to match its _ASDisplayLayer
counterpart -- `displaySuspended` is more succinct and is a more
plausible name for a Cocoa BOOL property.
2014-12-02 18:06:11 -08:00
Ryan Nystrom
531be46dfd Cleaning up manual display per @secretiverhyme 2014-12-02 16:53:17 -08:00
Ryan Nystrom
8b0dbf7288 Manually display nodes
Added a sample project that will demonstrate how to manually display nodes. Removed the UIWindow hack that coupled display of nodes with Core Animation transactions.
2014-12-02 09:34:24 -08:00
Huy Nguyen
230520fe7e Support custom working-range logic. 2014-11-25 12:31:20 +02:00
Nadine Salter
38f8e63b01 Support fractional tuning parameters (fixes #112). 2014-11-18 14:15:01 -08:00
Huy Nguyen
0eb7e5fc39 Update ASRangeController to support ASCollectionView and no longer assume vertical scrolling when calculates working range. 2014-11-12 21:27:26 +02:00
Nadine Salter
6c9e499875 Minor ASRangeController improvements (fixes #81). 2014-11-07 15:51:55 -08:00
Nadine Salter
a3e78d1cee Support background colour and selection style on ASCellNodes.
Most UITableViewCell properties aren't useful in conjunction with
ASCellNode -- the system's UIView properties are unsupported for
performance reasons, and properties that configure them (e.g., content
indentation) don't affect custom node hierarchies.  This patch adds
support to _ASTableViewCell for the properties that *are* useful.

r=scottg
2014-11-03 17:45:40 -08:00
Nadine Salter
d0b7a015e8 Improve ASRangeController dealloc-safety.
(1) We can't size nodes without a delegate, and if our owning controller
has been deallocated, our delegate will be nil.  Handle this more
gracefully.

(2) Our teardown code needs to be executed on the main thread, but it's
conceivable that we might hit refcount 0 on a background queue.  Force
deallocation to occur on the main thread.

Closes #27.
2014-10-22 13:50:24 -07:00
Scott Goodson
c61b1c294c Several bug fixes for the 1.0 release of AsyncDisplayKit
Fixes:
- Usage of UIScreen in -[ASDisplayNode init]
  (the offending individual will be prosecuted)
- #38: Proper teardown of nodes owned by ASTableView / ASRangeController
- #34: Fix infinite recursion in very rare subclassing scenario
- #30: Avoid animating cell and section additions to ASTableView
- #19: Set a more reasonable default for maximum display concurrency

r=nadi
2014-10-14 20:53:25 -07:00
Scott Goodson
f7d91bb877 Implement -reclaimMemory API and switch to manually controlled content clearing.
ASDisplayNode and several subclasses had previously cleared memory-heavy
objects like the backing store and text layout manager when the node's
view
or layer is removed from a visible heirarchy.  This works great in any
system
that uses a "working range", where exiting the range removes the node
from
the hierarchy and reclaiming memory at that time is important.
However, for
standard UIViewController patterns (unused in Paper), this behavior
causes
highly undesirable thrashing (leading to visible flashes & wasteful
re-rendering of content).

After this change, node subclasses should implement -reclaimMemory if
they
need to perform any other cleanup besides backing store destruction
when they
leave a working range or other scenario where memory reduction is
valuable.

To trigger this behavior, calling code should use
-recursivelyReclaimMemory.

r=nadi
2014-10-14 18:45:56 -07:00
Nadine Salter
0adab165ec Minor ASRangeController correctness fix. 2014-10-01 16:02:41 -07:00
Nadine Salter
b8afd06b37 Fix issue #28. 2014-09-24 14:23:42 -07:00
Nadine Salter
f77f63878d Fix issue #27. 2014-09-24 14:23:31 -07:00
Nadine Salter
7dd94a6102 Merge in downstream changes.
Introduce `ASTableView`, a UITableView subclass that uses `ASCellNode`
instead of UITableViewCell.  Add working range support via
`ASRangeController`, which observes the visible range, maintains a
working range, and handles most ASDK machinery.  ASRangeController is
loosely-enough coupled that it should be easily adapted to
UICollectionView if that's desired in the future.

Notable considerations in the ASRangeController architecture:

* There's no sense rewriting UITableView -- the real win comes from
  using nodes instead of UITableViewCells (easily parallelisable
  computation, large number of cells vs. few table views, etc.).  So,
  use a UITableView with empty cells, using UITableViewCell's
  contentView as a host for arbitrary node hierarchies.

* Instead of lazy-loading cells the instant they're needed by
  UITableView, load them in advance.  Preload a substantial number of
  nodes in the direction of scroll, as well as a small buffer in the
  other direction.

* Maintain compatibility with UITableView's API, with one primary change
  -- consumer code yields configured ASCellNodes, not UITableViewCells.

* Don't use -tableView:heightForRowAtIndexPath:.  Nodes already compute
  their preferred sizes and cache results for use at layout-time, so
  ASTableView uses their calculatedSizes directly.

* Corollary:  ASTableView is only aware of nodes that have been sized.
  This means that, if a cell appears onscreen, it has layout data and
  can display a "realistic placeholder", e.g. by making its subnodes'
  background colour grey.

Other improvements:

* Remove dead references and update headers (fixes #7, #20).

* Rename `-[ASDisplayNode sizeToFit:]` to `-measure:` and fix
  `constrainedSizeForCalulatedSize` typo (fixes #15).

* Rename `-willAppear` and `-didDisappear` to `-willEnterHierarchy` and
  `-didExitHierarchy`.  Remove `-willDisappear` -- it was redundant, and
  there was no counterpart `-didAppear`.

* Rename `viewLoaded` to `nodeLoaded`.
2014-09-22 14:33:39 -07:00