-
Notifications
You must be signed in to change notification settings - Fork 368
Using Cosmos in a scroll view
The demo app contains a Performance screen that demonstrates how to use Cosmos in a table view. The Cosmos view can be embedded in a table view cell. If you do so, make sure to call prepareForReuse
function of the Cosmos view before it is reused.
public class PerformanceTableViewCell: UITableViewCell {
@IBOutlet var cosmosView: CosmosView!
override public func prepareForReuse() {
// Ensures the reused cosmos view is as good as new
cosmosView.prepareForReuse()
}
}
There is one nuance to be aware of if you are using Cosmos in a scroll view or a table view.
After the user started scrolling, the scroll view does not pass touches to its subviews and CosmosView
does not receive them. This may result in not receiving callbacks didFinishTouchingCosmos
and didTouchCosmos
when the scrollview is being scrolled.
The issue can be fixed by disabling Can cancel on scroll for the scroll view (or Cancellable Content Touches in older Xcode). This has a side effect, unfortunately. If you start interacting with CosmosView you can no longer scroll until you finish changing the rating.