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
13
14
15
16
17
18
19
20
# File 'lib/project/tutorial.rb', line 4

def self.new(pages, args={})
  tutorial = self.alloc.initWithNibName("ICETutorialController_iPhone", bundle: nil)

  # For some reason the ICETutorial CocoaPod has issues with disabling autoscrolling
  # It will scroll once (No matter what autoScrollEnabled is set to), and then stops on second page when disabled
  # This fixes that issue
  tutorial.autoScrollEnabled = args[:autoScrollEnabled] if args[:autoScrollEnabled] != nil
  tutorial.autoScrollLooping = args[:autoScrollLooping] if args[:autoScrollLooping] != nil
  tutorial.autoScrollDurationOnPage = args[:autoScrollDurationOnPage] || (args[:autoScrollEnabled] == true) ? tutorial.autoScrollDurationOnPage : Float::INFINITY

  tutorial.pages = pages
  tutorial.title = args[:title]
  tutorial.remove_buttons
  tutorial.button1 = args[:button1]
  tutorial.button2 = args[:button2]
  tutorial
end

Instance Method Details

#button1Object



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

def button1
  @button1
end

#button1=(button) ⇒ Object



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

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

#button2Object



68
69
70
# File 'lib/project/tutorial.rb', line 68

def button2
  @button2
end

#button2=(button) ⇒ Object



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

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

#center_pagerObject



72
73
74
75
76
# File 'lib/project/tutorial.rb', line 72

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



32
33
34
# File 'lib/project/tutorial.rb', line 32

def pages
  @pages
end

#pages=(pages) ⇒ Object



27
28
29
30
# File 'lib/project/tutorial.rb', line 27

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

#remove(v) ⇒ Object



78
79
80
81
# File 'lib/project/tutorial.rb', line 78

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



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

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

#titleObject



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

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

#title=(label) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'lib/project/tutorial.rb', line 36

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



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

def viewDidAppear(animated)
  super
  self.center_pager
end