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-1.0.7 motion-prime/screens/_orientations_mixin.rb
motion-prime-1.0.6 motion-prime/screens/_orientations_mixin.rb
motion-prime-1.0.5 motion-prime/screens/_orientations_mixin.rb
motion-prime-1.0.4 motion-prime/screens/_orientations_mixin.rb
motion-prime-1.0.3 motion-prime/screens/_orientations_mixin.rb
motion-prime-1.0.2 motion-prime/screens/_orientations_mixin.rb
motion-prime-1.0.1 motion-prime/screens/_orientations_mixin.rb
motion-prime-1.0.0 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.9.9.2 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.9.9.1 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.9.9 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.9.8 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.9.7 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.9.6 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.9.5 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.9.4 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.9.3 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.9.2 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.9.1 motion-prime/screens/_orientations_mixin.rb
motion-prime-0.9.0 motion-prime/screens/_orientations_mixin.rb