incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject ios commit: [CB-1315] Setting the view controller's view size in viewWillAppear, use rootViewController
Date Thu, 30 Aug 2012 23:20:02 GMT
Updated Branches:
  refs/heads/master 9510225b1 -> cb33d9ffa


[CB-1315] Setting the view controller's view size in viewWillAppear, use rootViewController

Starting in iOS 4, the recommended way for managing views and view controllers with respect
to a `UIWindow` instance is through UIWindow's `rootViewController` property, as opposed to
the previous method of adding the view via `addSubview`.  Updated the inheriting view controllers
and app delegates to follow the recommended pattern.

**Note:** This also requires moving the code that sets the default view's frame size to the
view controller's `viewWillAppear` method.  This code is managed in the consuming app's view
controller (as opposed to `CDVViewController`), in the interests of Cordova modularity in
developers' apps.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/cb33d9ff
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/cb33d9ff
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/cb33d9ff

Branch: refs/heads/master
Commit: cb33d9ffad9cf0096de8d9ceb4f98ea0b5cb98dc
Parents: 9510225
Author: Kevin Hawkins <khawkins@salesforce.com>
Authored: Tue Aug 7 11:31:30 2012 -0700
Committer: Shazron Abdullah <shazron@apache.org>
Committed: Thu Aug 30 16:18:44 2012 -0700

----------------------------------------------------------------------
 CordovaLib/CordovaLibApp/AppDelegate.m             |    6 +++---
 CordovaLib/CordovaLibApp/ViewController.m          |    9 +++++++++
 .../project/__TESTING__/Classes/AppDelegate.m      |    5 ++---
 .../__TESTING__/Classes/MainViewController.m       |    9 +++++++++
 4 files changed, 23 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/cb33d9ff/CordovaLib/CordovaLibApp/AppDelegate.m
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLibApp/AppDelegate.m b/CordovaLib/CordovaLibApp/AppDelegate.m
index 9e118b7..2a719d8 100644
--- a/CordovaLib/CordovaLibApp/AppDelegate.m
+++ b/CordovaLib/CordovaLibApp/AppDelegate.m
@@ -40,14 +40,14 @@
 
 - (void)createViewController {
     NSAssert(!self.viewController, @"ViewController already created.");
-    CGRect viewBounds = [[UIScreen mainScreen] applicationFrame];
     
     self.viewController = [[ViewController alloc] init];
     self.viewController.useSplashScreen = YES;
     self.viewController.wwwFolderName = @"www";
     self.viewController.startPage = @"index.html";
-    self.viewController.view.frame = viewBounds;
-
+    
+    // NOTE: To control the view's frame size, override [self.viewController viewWillAppear:]
in your view controller.
+    
     self.window.rootViewController = self.viewController;
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/cb33d9ff/CordovaLib/CordovaLibApp/ViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLibApp/ViewController.m b/CordovaLib/CordovaLibApp/ViewController.m
index 6259862..68c608b 100644
--- a/CordovaLib/CordovaLibApp/ViewController.m
+++ b/CordovaLib/CordovaLibApp/ViewController.m
@@ -25,6 +25,15 @@
 
 @implementation ViewController
 
+- (void)viewWillAppear:(BOOL)animated
+{
+    // Set the main view to utilize the entire application frame space of the device.
+    // Change this to suit your view's UI footprint needs in your application.
+    self.view.frame = [[UIScreen mainScreen] applicationFrame];
+    
+    [super viewWillAppear:animated];
+}
+
 - (void)viewDidLoad
 {
     [super viewDidLoad];

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/cb33d9ff/bin/templates/project/__TESTING__/Classes/AppDelegate.m
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/Classes/AppDelegate.m b/bin/templates/project/__TESTING__/Classes/AppDelegate.m
index c1b36fa..a6d5db1 100644
--- a/bin/templates/project/__TESTING__/Classes/AppDelegate.m
+++ b/bin/templates/project/__TESTING__/Classes/AppDelegate.m
@@ -66,14 +66,13 @@
     self.window = [[UIWindow alloc] initWithFrame:screenBounds];
     self.window.autoresizesSubviews = YES;
     
-    CGRect viewBounds = [[UIScreen mainScreen] applicationFrame];
-    
     self.viewController = [[MainViewController alloc] init];
     self.viewController.useSplashScreen = YES;
     self.viewController.wwwFolderName = @"www";
     self.viewController.startPage = @"index.html";
     self.viewController.invokeString = invokeString;
-    self.viewController.view.frame = viewBounds;
+
+    // NOTE: To control the view's frame size, override [self.viewController viewWillAppear:]
in your view controller.
     
     // check whether the current orientation is supported: if it is, keep it, rather than
forcing a rotation
     BOOL forceStartupRotation = YES;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/cb33d9ff/bin/templates/project/__TESTING__/Classes/MainViewController.m
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/Classes/MainViewController.m b/bin/templates/project/__TESTING__/Classes/MainViewController.m
index b4c8e00..d0a55bf 100644
--- a/bin/templates/project/__TESTING__/Classes/MainViewController.m
+++ b/bin/templates/project/__TESTING__/Classes/MainViewController.m
@@ -48,6 +48,15 @@
 
 #pragma mark - View lifecycle
 
+- (void)viewWillAppear:(BOOL)animated
+{
+    // Set the main view to utilize the entire application frame space of the device.
+    // Change this to suit your view's UI footprint needs in your application.
+    self.view.frame = [[UIScreen mainScreen] applicationFrame];
+    
+    [super viewWillAppear:animated];
+}
+
 - (void) viewDidLoad
 {
     [super viewDidLoad];


Mime
View raw message