Class: UIControlController

Inherits:
UIViewController show all
Defined in:
app/uicontrol_controller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from UIViewController

#<<, #dismiss_modal, #pop, #present_modal, #present_modal_in_nav, #push, #sugarcube_cleanup, #to_s

Instance Attribute Details

#button1Object (readonly)

Returns the value of attribute button1.



2
3
4
# File 'app/uicontrol_controller.rb', line 2

def button1
  @button1
end

#button2Object (readonly)

Returns the value of attribute button2.



3
4
5
# File 'app/uicontrol_controller.rb', line 3

def button2
  @button2
end

#eventObject (readonly)

Returns the value of attribute event.



6
7
8
# File 'app/uicontrol_controller.rb', line 6

def event
  @event
end

#touchedObject (readonly)

Returns the value of attribute touched.



4
5
6
# File 'app/uicontrol_controller.rb', line 4

def touched
  @touched
end

#touched_1Object (readonly)

Returns the value of attribute touched_1.



7
8
9
# File 'app/uicontrol_controller.rb', line 7

def touched_1
  @touched_1
end

#touched_2Object (readonly)

Returns the value of attribute touched_2.



8
9
10
# File 'app/uicontrol_controller.rb', line 8

def touched_2
  @touched_2
end

#touched_countObject (readonly)

Returns the value of attribute touched_count.



5
6
7
# File 'app/uicontrol_controller.rb', line 5

def touched_count
  @touched_count
end

Instance Method Details

#loadViewObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/uicontrol_controller.rb', line 18

def loadView
  super.tap do
    @button1 = UIButton.rounded
    @button1.setTitle('one', forState: UIControlStateNormal)
    @button1.sizeToFit
    @button1.center = self.view.center
    self.view << @button1

    @button2 = UIButton.rounded
    @button2.setTitle('two', forState: UIControlStateNormal)
    @button2.sizeToFit
    @button2.center = [@button1.center.x, @button1.center.y + 30]
    @button1.center = [@button1.center.x, @button1.center.y - 30]
    self.view << @button2

    @button1.on :touch do |sender,event|
      @touched_1 = true
      @touched = sender
      @touched_count += 1
    end

    @button2.on :touch do |sender,event|
      @touched_2 = true
      @touched = sender
      @touched_count += 1
    end

    reset
  end
end

#resetObject



10
11
12
13
14
15
16
# File 'app/uicontrol_controller.rb', line 10

def reset
  @touched = nil
  @touched_count = 0
  @event = nil
  @touched_1 = false
  @touched_2 = false
end