diff options
Diffstat (limited to 'iPhone/FixMyStreet/Classes/MainViewController.m')
-rw-r--r-- | iPhone/FixMyStreet/Classes/MainViewController.m | 76 |
1 files changed, 47 insertions, 29 deletions
diff --git a/iPhone/FixMyStreet/Classes/MainViewController.m b/iPhone/FixMyStreet/Classes/MainViewController.m index 289da35..0df74a0 100644 --- a/iPhone/FixMyStreet/Classes/MainViewController.m +++ b/iPhone/FixMyStreet/Classes/MainViewController.m @@ -6,9 +6,9 @@ to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -19,17 +19,17 @@ // // MainViewController.h -// cordova1.8.0 +// cordova-2.2 // -// 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 "MainViewController.h" @implementation MainViewController -- (id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +- (id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { @@ -38,36 +38,52 @@ return self; } -- (void) didReceiveMemoryWarning +- (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; - + // Release any cached data, images, etc that aren't in use. } #pragma mark - View lifecycle -- (void) viewDidLoad +- (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. + + UIView* rootView = [[[[UIApplication sharedApplication] keyWindow] rootViewController] view]; + CGRect webViewFrame = [[[rootView subviews] objectAtIndex:0] frame]; // first subview is the UIWebView + + if (CGRectEqualToRect(webViewFrame, CGRectZero)) { // UIWebView is sized according to its parent, here it hasn't been sized yet + self.view.frame = [[UIScreen mainScreen] applicationFrame]; // size UIWebView's parent according to application frame, which will in turn resize the UIWebView + } + + [super viewWillAppear:animated]; +} + +- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view from its nib. } -- (void) viewDidUnload +- (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } -- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return [super shouldAutorotateToInterfaceOrientation:interfaceOrientation]; } /* Comment out the block below to over-ride */ + /* - (CDVCordovaView*) newCordovaViewWithFrame:(CGRect)bounds { @@ -76,24 +92,25 @@ */ /* Comment out the block below to over-ride */ + /* #pragma CDVCommandDelegate implementation - (id) getCommandInstance:(NSString*)className { - return [super getCommandInstance:className]; + return [super getCommandInstance:className]; } - (BOOL) execute:(CDVInvokedUrlCommand*)command { - return [super execute:command]; + return [super execute:command]; } - (NSString*) pathForResource:(NSString*)resourcepath; { - return [super pathForResource:resourcepath]; + return [super pathForResource:resourcepath]; } - + - (void) registerPlugin:(CDVPlugin*)plugin withClassName:(NSString*)className { return [super registerPlugin:plugin withClassName:className]; @@ -102,38 +119,39 @@ #pragma UIWebDelegate implementation -- (void) webViewDidFinishLoad:(UIWebView*) theWebView +- (void)webViewDidFinishLoad:(UIWebView*)theWebView { - // only valid if ___PROJECTNAME__-Info.plist specifies a protocol to handle - if (self.invokeString) - { + // only valid if ___PROJECTNAME__-Info.plist specifies a protocol to handle + if (self.invokeString) { // this is passed before the deviceready event is fired, so you can access it in js when you receive deviceready + NSLog(@"DEPRECATED: window.invokeString - use the window.handleOpenURL(url) function instead, which is always called when the app is launched through a custom scheme url."); NSString* jsString = [NSString stringWithFormat:@"var invokeString = \"%@\";", self.invokeString]; [theWebView stringByEvaluatingJavaScriptFromString:jsString]; - } - - // Black base color for background matches the native apps - theWebView.backgroundColor = [UIColor blackColor]; + } - return [super webViewDidFinishLoad:theWebView]; + // Black base color for background matches the native apps + theWebView.backgroundColor = [UIColor blackColor]; + + return [super webViewDidFinishLoad:theWebView]; } /* Comment out the block below to over-ride */ + /* -- (void) webViewDidStartLoad:(UIWebView*)theWebView +- (void) webViewDidStartLoad:(UIWebView*)theWebView { - return [super webViewDidStartLoad:theWebView]; + return [super webViewDidStartLoad:theWebView]; } -- (void) webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error +- (void) webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error { - return [super webView:theWebView didFailLoadWithError:error]; + return [super webView:theWebView didFailLoadWithError:error]; } - (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType { - return [super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType]; + return [super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType]; } */ |