Module: MotionPrime::ScreenOrientationsMixin

Included in:
ScreenBaseMixin
Defined in:
motion-prime/screens/_orientations_mixin.rb

Instance Method Summary collapse

Instance Method Details

#should_rotate(orientation) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'motion-prime/screens/_orientations_mixin.rb', line 3

def should_rotate(orientation)
  case orientation
  when UIInterfaceOrientationPortrait
    return supported_orientation?("UIInterfaceOrientationPortrait")
  when UIInterfaceOrientationLandscapeLeft
    return supported_orientation?("UIInterfaceOrientationLandscapeLeft")
  when UIInterfaceOrientationLandscapeRight
    return supported_orientation?("UIInterfaceOrientationLandscapeRight")
  when UIInterfaceOrientationPortraitUpsideDown
    return supported_orientation?("UIInterfaceOrientationPortraitUpsideDown")
  else
    false
  end
end

#supported_orientation?(orientation) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'motion-prime/screens/_orientations_mixin.rb', line 18

def supported_orientation?(orientation)
  NSBundle.mainBundle.infoDictionary["UISupportedInterfaceOrientations"].include?(orientation)
end

#supported_orientationsObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'motion-prime/screens/_orientations_mixin.rb', line 22

def supported_orientations
  ors = 0
  NSBundle.mainBundle.infoDictionary["UISupportedInterfaceOrientations"].each do |ori|
    case ori
    when "UIInterfaceOrientationPortrait"
      ors |= UIInterfaceOrientationMaskPortrait
    when "UIInterfaceOrientationLandscapeLeft"
      ors |= UIInterfaceOrientationMaskLandscapeLeft
    when "UIInterfaceOrientationLandscapeRight"
      ors |= UIInterfaceOrientationMaskLandscapeRight
    when "UIInterfaceOrientationPortraitUpsideDown"
      ors |= UIInterfaceOrientationMaskPortraitUpsideDown
    end
  end
  ors
end