Method: UIControl#off

Defined in:
lib/ios/sugarcube-events/uicontrol.rb

#off(*events) ⇒ Object

Removes all events that were bound with ‘on`. See symbol.rb for the uicontrolevent constant aliases.

Examples:

button.off(:touch)
button.off(:touch_up_outside, :touch_cancel)
button.off  # all events


33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ios/sugarcube-events/uicontrol.rb', line 33

def off(*events)
  if events.length == 0
    events = sugarcube_callbacks.keys
  end

  events.each do |event|
    event = event.uicontrolevent if event.respond_to?(:uicontrolevent)

    sugarcube_callbacks(event).each do |handler|
      self.removeTarget(handler, action:'call:event:', forControlEvents:event)
    end
    sugarcube_callbacks.delete(event)
  end

  self
end