Class: Indoctrinator::Tutorial

Inherits:
ICETutorialController
  • Object
show all
Defined in:
lib/project/tutorial.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(pages, args = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/project/tutorial.rb', line 4

def self.new(pages, args={})
  tutorial = self.alloc.initWithNibName("ICETutorialController_iPhone", bundle: nil) 
  tutorial.pages = pages
  tutorial.title = args[:title]
  tutorial.remove_buttons
  tutorial.button1 = args[:button1]
  tutorial.button2 = args[:button2]
  tutorial
end

Instance Method Details

#button1Object



51
52
53
# File 'lib/project/tutorial.rb', line 51

def button1
  @button1
end

#button1=(button) ⇒ Object



46
47
48
49
# File 'lib/project/tutorial.rb', line 46

def button1=(button)
  @button1 = button
  self.view.addSubview @button1
end

#button2Object



60
61
62
# File 'lib/project/tutorial.rb', line 60

def button2
  @button2
end

#button2=(button) ⇒ Object



55
56
57
58
# File 'lib/project/tutorial.rb', line 55

def button2=(button)
  @button2 = button
  self.view.addSubview @button2
end

#center_pagerObject



64
65
66
67
68
# File 'lib/project/tutorial.rb', line 64

def center_pager
  screen_size = UIScreen.mainScreen.bounds.size
  pc = self.view.subviews.find{ |v| v.is_a?(UIPageControl) }
  pc.frame = [[0, screen_size.height - 100],[screen_size.width, 36]]
end

#pagesObject



24
25
26
# File 'lib/project/tutorial.rb', line 24

def pages
  @pages
end

#pages=(pages) ⇒ Object



19
20
21
22
# File 'lib/project/tutorial.rb', line 19

def pages=(pages)
  @pages = pages
  self.setPages(Array(pages))
end

#remove(v) ⇒ Object



70
71
72
73
# File 'lib/project/tutorial.rb', line 70

def remove(v)
  self.send(v).removeFromSuperview if self.send(v) && self.send(v).respond_to?(:removeFromSuperview)
  self.instance_variable_set "@#{v}", nil
end

#remove_buttonsObject



42
43
44
# File 'lib/project/tutorial.rb', line 42

def remove_buttons
  self.view.subviews.select{ |v| v.is_a?(UIButton) }.each(&:removeFromSuperview)
end

#titleObject



38
39
40
# File 'lib/project/tutorial.rb', line 38

def title
  @title ||= self.view.subviews.find{ |v| v.is_a?(UILabel) }
end

#title=(label) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/project/tutorial.rb', line 28

def title=(label)
  return self.remove(:title) unless label
  if label.is_a?(String)
    self.title.text = label if self.title
  else
    self.remove(:title)
    self.view.addSubview label
  end
end

#viewDidAppear(animated) ⇒ Object



14
15
16
17
# File 'lib/project/tutorial.rb', line 14

def viewDidAppear(animated)
  super
  self.center_pager
end