aboutsummaryrefslogtreecommitdiffstats
path: root/iPhone/FixMyStreet/Classes/MainViewController.m
diff options
context:
space:
mode:
Diffstat (limited to 'iPhone/FixMyStreet/Classes/MainViewController.m')
-rw-r--r--iPhone/FixMyStreet/Classes/MainViewController.m110
1 files changed, 63 insertions, 47 deletions
diff --git a/iPhone/FixMyStreet/Classes/MainViewController.m b/iPhone/FixMyStreet/Classes/MainViewController.m
index 0df74a0..7d3871b 100644
--- a/iPhone/FixMyStreet/Classes/MainViewController.m
+++ b/iPhone/FixMyStreet/Classes/MainViewController.m
@@ -19,7 +19,7 @@
//
// MainViewController.h
-// cordova-2.2
+// tmp_ios
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
@@ -33,7 +33,22 @@
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
- // Custom initialization
+ // Uncomment to override the CDVCommandDelegateImpl used
+ // _commandDelegate = [[MainCommandDelegate alloc] initWithViewController:self];
+ // Uncomment to override the CDVCommandQueue used
+ // _commandQueue = [[MainCommandQueue alloc] initWithViewController:self];
+ }
+ return self;
+}
+
+- (id)init
+{
+ self = [super init];
+ if (self) {
+ // Uncomment to override the CDVCommandDelegateImpl used
+ // _commandDelegate = [[MainCommandDelegate alloc] initWithViewController:self];
+ // Uncomment to override the CDVCommandQueue used
+ // _commandQueue = [[MainCommandQueue alloc] initWithViewController:self];
}
return self;
}
@@ -46,19 +61,12 @@
// Release any cached data, images, etc that aren't in use.
}
-#pragma mark - View lifecycle
+#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.
-
- 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
- }
+ // View defaults to full size. If you want to customize the view's size, or its subviews (e.g. webView),
+ // you can do so here.
[super viewWillAppear:animated];
}
@@ -91,44 +99,10 @@
}
*/
-/* Comment out the block below to over-ride */
-
-/*
-#pragma CDVCommandDelegate implementation
-
-- (id) getCommandInstance:(NSString*)className
-{
- return [super getCommandInstance:className];
-}
-
-- (BOOL) execute:(CDVInvokedUrlCommand*)command
-{
- return [super execute:command];
-}
-
-- (NSString*) pathForResource:(NSString*)resourcepath;
-{
- return [super pathForResource:resourcepath];
-}
-
-- (void) registerPlugin:(CDVPlugin*)plugin withClassName:(NSString*)className
-{
- return [super registerPlugin:plugin withClassName:className];
-}
-*/
-
-#pragma UIWebDelegate implementation
+#pragma mark UIWebDelegate implementation
- (void)webViewDidFinishLoad:(UIWebView*)theWebView
{
- // 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];
@@ -156,3 +130,45 @@
*/
@end
+
+@implementation MainCommandDelegate
+
+/* To override the methods, uncomment the line in the init function(s)
+ in MainViewController.m
+ */
+
+#pragma mark CDVCommandDelegate implementation
+
+- (id)getCommandInstance:(NSString*)className
+{
+ return [super getCommandInstance:className];
+}
+
+/*
+ NOTE: this will only inspect execute calls coming explicitly from native plugins,
+ not the commandQueue (from JavaScript). To see execute calls from JavaScript, see
+ MainCommandQueue below
+*/
+- (BOOL)execute:(CDVInvokedUrlCommand*)command
+{
+ return [super execute:command];
+}
+
+- (NSString*)pathForResource:(NSString*)resourcepath;
+{
+ return [super pathForResource:resourcepath];
+}
+
+@end
+
+@implementation MainCommandQueue
+
+/* To override, uncomment the line in the init function(s)
+ in MainViewController.m
+ */
+- (BOOL)execute:(CDVInvokedUrlCommand*)command
+{
+ return [super execute:command];
+}
+
+@end