use UIApplication.sharedApplication.statusBarOrientation

This commit is contained in:
Robert Malko
2014-04-16 17:17:54 -04:00
parent 30f128f21b
commit f4b49fd39c
3 changed files with 20 additions and 19 deletions

View File

@@ -119,9 +119,9 @@ for **bleeding edge**, add this to your `Gemfile`:
*Clone this repo and run the example app to see an example of use.* *Clone this repo and run the example app to see an example of use.*
git clone git@github.com:infinitered/rmq.git git clone git@github.com:infinitered/rmq.git
cd rmq cd rmq
rake rake
The example app works in any orientation, on both iPhone and iPad. Notice how the benchmark popup is done with RMQ, then think about how you'd do that without it. The example app works in any orientation, on both iPhone and iPad. Notice how the benchmark popup is done with RMQ, then think about how you'd do that without it.
@@ -268,7 +268,7 @@ I recomend you play around with it, do this:
- my_view_instance - my_view_instance
- text: 'you can select via attributes also' - text: 'you can select via attributes also'
- :another_tag, UILabel, text: 'an array' <- this is an "or", use .and for and - :another_tag, UILabel, text: 'an array' <- this is an "or", use .and for and
The more common use is to select any view or views you have assigned to variables, then perform actions on them. For example: The more common use is to select any view or views you have assigned to variables, then perform actions on them. For example:
```ruby ```ruby
@@ -377,8 +377,8 @@ The rest of traversing isn't used too often, but when you need it, it's super ha
- all - all
- closest - closest
- find - find
These are less common: These are less common:
- and - and
- not - not
@@ -500,7 +500,7 @@ rmq(UIView).on(:tap){|sender| rmq(sender).hide}
# Adding an Event during creation # Adding an Event during creation
view_q = rmq.append(UIView).on(:tap) do |sender, event| view_q = rmq.append(UIView).on(:tap) do |sender, event|
# do something here # do something here
end end
# removing an Event # removing an Event
@@ -845,7 +845,7 @@ rmq.device.iphone?
rmq.device.four_inch? rmq.device.four_inch?
rmq.device.retina? rmq.device.retina?
# return values are :unknown, :portrait, :portrait_upside_down, :landscape_Left, # return values are :unknown, :portrait, :portrait_upside_down, :landscape_left,
# :landscape_right, :face_up, :face_down # :landscape_right, :face_up, :face_down
rmq.device.orientation rmq.device.orientation
rmq.device.landscape? rmq.device.landscape?
@@ -1314,7 +1314,7 @@ end
``` ```
##### UIControlStyler ##### UIControlStyler
Nothing yet Nothing yet
##### UILabelStyler ##### UILabelStyler

View File

@@ -58,11 +58,12 @@ module RubyMotionQuery
# @return :unknown or from ORIENTATIONS # @return :unknown or from ORIENTATIONS
def orientation def orientation
ORIENTATIONS[UIDevice.currentDevice.orientation] || :unknown orientation = UIApplication.sharedApplication.statusBarOrientation
ORIENTATIONS[orientation] || :unknown
end end
def landscape? def landscape?
Device.orientation == :landscape_Left || Device.orientation == :landscape_right Device.orientation == :landscape_left || Device.orientation == :landscape_right
end end
def portrait? def portrait?
@@ -77,7 +78,7 @@ module RubyMotionQuery
UIDeviceOrientationUnknown => :unknown, UIDeviceOrientationUnknown => :unknown,
UIDeviceOrientationPortrait => :portrait, UIDeviceOrientationPortrait => :portrait,
UIDeviceOrientationPortraitUpsideDown => :portrait_upside_down, UIDeviceOrientationPortraitUpsideDown => :portrait_upside_down,
UIDeviceOrientationLandscapeLeft => :landscape_Left, UIDeviceOrientationLandscapeLeft => :landscape_left,
UIDeviceOrientationLandscapeRight => :landscape_right, UIDeviceOrientationLandscapeRight => :landscape_right,
UIDeviceOrientationFaceUp => :face_up, UIDeviceOrientationFaceUp => :face_up,
UIDeviceOrientationFaceDown => :face_down UIDeviceOrientationFaceDown => :face_down

View File

@@ -52,7 +52,7 @@ module RubyMotionQuery
end end
def styler_for(view) def styler_for(view)
# TODO should have a pool of stylers to reuse, or just assume single threaded and # TODO should have a pool of stylers to reuse, or just assume single threaded and
# memoize this, however if you do that, make sure the dev doesn't retain them in a var # memoize this, however if you do that, make sure the dev doesn't retain them in a var
custom_stylers(view) || begin custom_stylers(view) || begin
case view case view
@@ -110,13 +110,13 @@ module RubyMotionQuery
unless Stylesheet.application_was_setup unless Stylesheet.application_was_setup
Stylesheet.application_was_setup = true Stylesheet.application_was_setup = true
application_setup application_setup
end end
setup setup
end end
def application_setup def application_setup
# Override to do your overall setup for your applications. This # Override to do your overall setup for your applications. This
# is where you want to add your custom fonts and colors # is where you want to add your custom fonts and colors
# This only gets called once # This only gets called once
end end
@@ -175,11 +175,11 @@ module RubyMotionQuery
end end
def app_width def app_width
landscape? ? app_size.width : app_size.height portrait? ? app_size.width : app_size.height
end end
def app_height def app_height
landscape? ? app_size.height : app_size.width portrait? ? app_size.height : app_size.width
end end
def app_size def app_size
@@ -187,11 +187,11 @@ module RubyMotionQuery
end end
def screen_width def screen_width
landscape? ? screen_size.width : screen_size.height portrait? ? screen_size.width : screen_size.height
end end
def screen_height def screen_height
landscape? ? screen_size.height : screen_size.width portrait? ? screen_size.height : screen_size.width
end end
def screen_size def screen_size