Sha256: bd9d45a51bf6557e2d3d10a02cb13b0b537c04b78a1c887a2892f3a68f21d0aa

Contents?: true

Size: 1.41 KB

Versions: 65

Compression:

Stored size: 1.41 KB

Contents

module MotionPrime
  module ScreenOrientationsMixin
    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

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

    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
  end
end

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
motion-prime-0.8.12 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.8.11 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.8.10 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.8.9 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.8.8 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.8.7 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.8.6 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.8.5 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.8.4 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.8.3 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.8.2 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.8.1 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.8.0 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.7.2 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.7.1 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.7.0 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.6.0 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.5.7 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.5.6 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.5.5 motion-prime/screens/_orientations_mixin.rb