Sha256: 208e1e7debacdb631ba9bcfb397b7aaaf35598b86246551eaee8c5d2afb4c5fc
Contents?: true
Size: 1.93 KB
Versions: 3
Compression:
Stored size: 1.93 KB
Contents
class RMXView < UIView include RMXCommonMethods include RMXSetAttributes attr_accessor :updatedSize, :reportSizeChanges def rmx_dealloc NSNotificationCenter.defaultCenter.removeObserver(self) super end def prepare end def setup end def init s = super prepare setUserInteractionEnabled(false) setup s end def setUserInteractionEnabled(bool) @userInteractionEnabled = bool end def self.create(attributes={}) x = new x.attributes = attributes x end # normal userInteractionEnabled means the view and all subviews can't be clicked. what we normally # want is subviews to be clickable, but not the parent. this custom hitTest allows that behavior. def hitTest(point, withEvent:event) s = super if s == self && @userInteractionEnabled == false return nil end s end def requiresConstraintBasedLayout true end def layoutSubviews s = super if reportSizeChanges Dispatch::Queue.main.async do size = systemLayoutSizeFittingSize(UILayoutFittingCompressedSize) unless updatedSize == size self.updatedSize = size RMX.new(self).trigger(:updatedSize, size) if tableView = is_or_within_a?(UITableView) if tableView.delegate.respondsToSelector('tableView:viewDidUpdateSize:') tableView.delegate.tableView(tableView, viewDidUpdateSize:self) end # p "unbounced reload" RMX.new(self).debounce(:reloadTableUpdatedSize) do # p "debounced reload" if controller = tableView.lAncestorViewController if controller.viewState == :viewDidAppear tableView.beginUpdates tableView.endUpdates else tableView.reloadData end end end end end end end s end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rmx-0.6.2 | lib/motion/RMXView.rb |
rmx-0.6.1 | lib/motion/RMXView.rb |
rmx-0.6.0 | lib/motion/RMXView.rb |