From a192c00d07292a3965f1a9f8a350bc879dc2267a Mon Sep 17 00:00:00 2001 From: Jamon Holmgren Date: Tue, 4 Jun 2013 12:37:53 -0700 Subject: [PATCH] Fixing issue #109 - iOS 6 doesn't call screen shouldAutorotate when in navigation bar. Added tests too. --- Gemfile.lock | 2 +- lib/ProMotion/cocoatouch/NavigationController.rb | 5 ++++- spec/unit/screen_spec.rb | 13 +++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) 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