UIView (or UIViewController)

  • viewDidLoad() - after interface file loaded, outlets reference objects. Override if only need to configure once
  • viewWillAppear(_:) - just before VC’s view added to window. Override if needs to happen each time VC’s view appears on screen
  • loadView() - override to create a VC’s view programmatically

Programatic View Setup

                  action: #selector(myCustomFuncName(_:)),
                  for: .valueChanged)
@objc func myCustomFuncName(_ segControl: UISegmentedControl) {…}

Ways to Trigger Actions

  • @IBActions (example: UIButton)
  • Delegates (example: UITableDelegate)
  • Callbacks (example: UIContextualAction)
  • addTarget() #selectors (example: UISegmentedControl .valueChanged)
  • UIActions (example: UIDatePicker)

Pop Up Buttons

let options = [UIAction(title: "Some Title", state: .on) {…}]
popUpButton.menu = UIMenu(children: options)

Expandable Text Views