diff options
Diffstat (limited to 'phonegap/iPhone/FixMyStreet/Classes')
-rw-r--r-- | phonegap/iPhone/FixMyStreet/Classes/AppDelegate.h | 19 | ||||
-rw-r--r-- | phonegap/iPhone/FixMyStreet/Classes/AppDelegate.m | 64 | ||||
-rw-r--r-- | phonegap/iPhone/FixMyStreet/Classes/MainViewController.h | 6 |
3 files changed, 39 insertions, 50 deletions
diff --git a/phonegap/iPhone/FixMyStreet/Classes/AppDelegate.h b/phonegap/iPhone/FixMyStreet/Classes/AppDelegate.h index cee4240b1..5c258f148 100644 --- a/phonegap/iPhone/FixMyStreet/Classes/AppDelegate.h +++ b/phonegap/iPhone/FixMyStreet/Classes/AppDelegate.h @@ -19,32 +19,27 @@ // // AppDelegate.h -// cordova1.8.0 +// tmp_cordova // -// Created by Struan Donald on 08/06/2012. -// Copyright __MyCompanyName__ 2012. All rights reserved. +// Created by ___FULLUSERNAME___ on ___DATE___. +// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. // #import <UIKit/UIKit.h> -#ifdef CORDOVA_FRAMEWORK - #import <Cordova/CDVViewController.h> -#else - #import "CDVViewController.h" -#endif - +#import <Cordova/CDVViewController.h> @interface AppDelegate : NSObject < UIApplicationDelegate > { } // invoke string is passed to your app on launch, this is only valid if you -// edit cordova1.8.0-Info.plist to add a protocol +// edit tmp_cordova-Info.plist to add a protocol // a simple tutorial can be found here : // http://iphonedevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html -@property (nonatomic, retain) IBOutlet UIWindow* window; -@property (nonatomic, retain) IBOutlet CDVViewController* viewController; +@property (nonatomic, strong) IBOutlet UIWindow* window; +@property (nonatomic, strong) IBOutlet CDVViewController* viewController; @end diff --git a/phonegap/iPhone/FixMyStreet/Classes/AppDelegate.m b/phonegap/iPhone/FixMyStreet/Classes/AppDelegate.m index ad518dc80..b1c862eee 100644 --- a/phonegap/iPhone/FixMyStreet/Classes/AppDelegate.m +++ b/phonegap/iPhone/FixMyStreet/Classes/AppDelegate.m @@ -19,22 +19,16 @@ // // AppDelegate.m -// cordova1.8.0 +// tmp_cordova // -// Created by Struan Donald on 08/06/2012. -// Copyright __MyCompanyName__ 2012. All rights reserved. +// Created by ___FULLUSERNAME___ on ___DATE___. +// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. // #import "AppDelegate.h" #import "MainViewController.h" -#ifdef CORDOVA_FRAMEWORK - #import <Cordova/CDVPlugin.h> - #import <Cordova/CDVURLProtocol.h> -#else - #import "CDVPlugin.h" - #import "CDVURLProtocol.h" -#endif +#import <Cordova/CDVPlugin.h> @implementation AppDelegate @@ -49,9 +43,8 @@ NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; [cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways]; - [CDVURLProtocol registerURLProtocol]; - - return [super init]; + self = [super init]; + return self; } #pragma UIApplicationDelegate implementation @@ -66,21 +59,20 @@ if (url && [url isKindOfClass:[NSURL class]]) { invokeString = [url absoluteString]; - NSLog(@"cordova1.8.0 launchOptions = %@", url); + NSLog(@"tmp_cordova launchOptions = %@", url); } CGRect screenBounds = [[UIScreen mainScreen] bounds]; - self.window = [[[UIWindow alloc] initWithFrame:screenBounds] autorelease]; + self.window = [[UIWindow alloc] initWithFrame:screenBounds]; self.window.autoresizesSubviews = YES; - CGRect viewBounds = [[UIScreen mainScreen] applicationFrame]; - - self.viewController = [[[MainViewController alloc] init] autorelease]; + 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; @@ -92,30 +84,34 @@ } if (UIDeviceOrientationIsValidInterfaceOrientation(curDevOrientation)) { - for (NSNumber *orient in self.viewController.supportedOrientations) { - if ([orient intValue] == curDevOrientation) { - forceStartupRotation = NO; - break; - } - } + if ([self.viewController supportsOrientation:curDevOrientation]) { + forceStartupRotation = NO; + } } if (forceStartupRotation) { - NSLog(@"supportedOrientations: %@", self.viewController.supportedOrientations); - // The first item in the supportedOrientations array is the start orientation (guaranteed to be at least Portrait) - UIInterfaceOrientation newOrient = [[self.viewController.supportedOrientations objectAtIndex:0] intValue]; + UIInterfaceOrientation newOrient; + if ([self.viewController supportsOrientation:UIInterfaceOrientationPortrait]) + newOrient = UIInterfaceOrientationPortrait; + else if ([self.viewController supportsOrientation:UIInterfaceOrientationLandscapeLeft]) + newOrient = UIInterfaceOrientationLandscapeLeft; + else if ([self.viewController supportsOrientation:UIInterfaceOrientationLandscapeRight]) + newOrient = UIInterfaceOrientationLandscapeRight; + else + newOrient = UIInterfaceOrientationPortraitUpsideDown; + NSLog(@"AppDelegate forcing status bar to: %d from: %d", newOrient, curDevOrientation); [[UIApplication sharedApplication] setStatusBarOrientation:newOrient]; } - [self.window addSubview:self.viewController.view]; + self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible]; return YES; } // this happens while we are running ( in the background, or from within our own app ) -// only valid if cordova1.8.0-Info.plist specifies a protocol to handle +// only valid if tmp_cordova-Info.plist specifies a protocol to handle - (BOOL) application:(UIApplication*)application handleOpenURL:(NSURL*)url { if (!url) { @@ -132,9 +128,11 @@ return YES; } -- (void) dealloc -{ - [super dealloc]; +- (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window +{ + // IPhone doesn't support upside down by default, while the IPad does. Override to allow all orientations always, and let the root view controller decide whats allowed (the supported orientations mask gets intersected). + NSUInteger supportedInterfaceOrientations = (1 << UIInterfaceOrientationPortrait) | (1 << UIInterfaceOrientationLandscapeLeft) | (1 << UIInterfaceOrientationLandscapeRight) | (1 << UIInterfaceOrientationPortraitUpsideDown); + return supportedInterfaceOrientations; } @end diff --git a/phonegap/iPhone/FixMyStreet/Classes/MainViewController.h b/phonegap/iPhone/FixMyStreet/Classes/MainViewController.h index 3f48936da..c2b68deb8 100644 --- a/phonegap/iPhone/FixMyStreet/Classes/MainViewController.h +++ b/phonegap/iPhone/FixMyStreet/Classes/MainViewController.h @@ -25,11 +25,7 @@ // Copyright __MyCompanyName__ 2012. All rights reserved. // -#ifdef CORDOVA_FRAMEWORK - #import <Cordova/CDVViewController.h> -#else - #import "CDVViewController.h" -#endif +#import <Cordova/CDVViewController.h> @interface MainViewController : CDVViewController |