MotionInMotion Episode 18 - Custom Table View Cells & AutoLayout
Custom Table View Cells & AutoLayout - MotionInMotion
TaskアプリでCustom Cell & AutoLayout
- スライドと説明つきで1時間
- futuresimple/FSVerticalTabBarController · GitHub
- Custom Cell
- easy
- subclass UITableViewCell
- Constraints
- Visual Format Language
- class TextField < UITextField
- def textRectForBounds(bounds)
- CGRectMake(bounds.origin.x + 10, bounds.origin.y, bounds.size.width - 10, bounds.size.height)
- placeholderRectForBounds
- editingRectForBounds
- def textRectForBounds(bounds)
- multi line UILabel
- self.numberOfLines = 0
- views
- due_at_label.rb
- name_label.rb
- notes_indicator.rb
- task_cell.rb
- task_view.rb
- text_field.rb
- tick_button.rb
- RemoteManager
- @manager.HTTPClient.setDefaultHeader('Device-ID', value: UIDevice.currentDevice.identifierForVendor.UUIDString)
- TaskListController
- cell間のセパレータの線の調整
- viewDidLoad
- self.view.separatorInset = UIEdgeInsetsZero
- cell.configure
- TaskCell
- initWithStyle(style, reuseIdentifier: reuse_identifier)
- super
- @tick_button.setTranslatesAutoresizingMaskIntoConstraints(false)
- configure
- self.contentView.subviews.each do |sv|
- sv.configure(data)
- self.setNeedsUpdateConstraints
- self.setNeedsLayout
- self.contentView.subviews.each do |sv|
- current_height_for_width
- @name_label.text.boundingRectWithSize ...
- initWithStyle(style, reuseIdentifier: reuse_identifier)
- TaskCell
- updateConstraints
- self.contentView.removeConstraints(@constraints.flatten)
- @constraints << NSLayoutConstraint.constraintsWithVisualFormat
- vertical
'V:|-7-[tick(44)]'
- horizontal
'H:|-1-[tick(44)]'
(implicit)
- vertical
- self.contentView.addConstraints(@constraints.flatten)
- AutoLayout
- nearest superview
- cross the view hierarchy
- defaults of motion layout
- centerx centery
- conflicts
- AutoLayout try to cancel one of those
- priority
- default 1000
- width
100@750