diff --git a/Gemfile.lock b/Gemfile.lock index c63cb0c..ca78261 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - ProMotion (0.7.0) + ProMotion (0.7.1) GEM remote: https://rubygems.org/ diff --git a/lib/ProMotion/cocoatouch/NavigationController.rb b/lib/ProMotion/cocoatouch/NavigationController.rb index ba7bd02..e702a29 100644 --- a/lib/ProMotion/cocoatouch/NavigationController.rb +++ b/lib/ProMotion/cocoatouch/NavigationController.rb @@ -1,4 +1,7 @@ module ProMotion class NavigationController < UINavigationController + def shouldAutorotate + visibleViewController.shouldAutorotate + end end -end \ No newline at end of file +end diff --git a/spec/unit/screen_spec.rb b/spec/unit/screen_spec.rb index ca5509b..b157831 100644 --- a/spec/unit/screen_spec.rb +++ b/spec/unit/screen_spec.rb @@ -43,6 +43,19 @@ describe "screen properties" do @screen.should_autorotate.should == true end + # Issue https://github.com/clearsightstudio/ProMotion/issues/109 + it "#should_autorotate should fire when shouldAutorotate fires when in a navigation bar" do + parent_screen = BasicScreen.new(nav_bar: true) + parent_screen.open @screen + @screen.mock!(:should_autorotate) { true.should == true } + parent_screen.navigationController.shouldAutorotate + end + + # <= iOS 5 only + it "#should_rotate(orientation) should fire when shouldAutorotateToInterfaceOrientation(orientation) fires" do + @screen.mock!(:should_rotate) { |orientation| orientation.should == UIInterfaceOrientationMaskPortrait } + @screen.shouldAutorotateToInterfaceOrientation(UIInterfaceOrientationMaskPortrait) + end describe "iOS lifecycle methods" do