Permalink
Browse files

Updated MapKit example.

  • Loading branch information...
1 parent cc49468 commit b1dd1fff0c055b682a36e07fecc35df28f94d488 @probablycorey committed Mar 5, 2011
@@ -3,7 +3,7 @@
//
// This seems to be a bug, or there is a runtime method I'm unaware of
-#import <Foundation/Foundation.h>
+#import <UIKit/UIKit.h>
@interface ProtocolLoader : NSObject <UIApplicationDelegate, UIWebViewDelegate, UIActionSheetDelegate, UIAlertViewDelegate, UISearchBarDelegate, UITextViewDelegate, UITabBarControllerDelegate> {}
@end
@@ -1,71 +0,0 @@
-// UITextInputTraits are inaccessable via the runtime (not sure why).
-// This is a hack to access them via wax
-
-#import <Foundation/Foundation.h>
-
-@interface WaxTextField : UITextField {}
-
-@end
-
-@implementation WaxTextField
-- (UITextAutocapitalizationType)autocapitalizationType {
- return [super autocapitalizationType];
-}
-
-- (void)setAutocapitalizationType:(UITextAutocapitalizationType)value {
- return [super setAutocapitalizationType:value];
-}
-
-
-- (void)autocorrectionType:(UITextAutocorrectionType)value {
- [super autocorrectionType];
-}
-
-- (void)setAutocorrectionType:(UITextAutocorrectionType)value {
- [super setAutocorrectionType:value];
-}
-
-
-- (UIKeyboardType)keyboardType {
- return [super keyboardType];
-}
-
-- (void)setKeyboardType:(UIKeyboardType)value {
- [super setKeyboardType:value];
-}
-
-- (UIKeyboardAppearance)keyboardAppearance {
- return [super keyboardAppearance];
-}
-
-- (void)setKeyboardAppearance:(UIKeyboardAppearance)value {
- [super setKeyboardAppearance:value];
-}
-
-
-- (UIReturnKeyType)returnKeyType {
- return [super returnKeyType];
-}
-
-- (void)setReturnKeyType:(UIReturnKeyType)value {
- [super setReturnKeyType:value];
-}
-
-
-- (BOOL)enablesReturnKeyAutomatically {
- return [super enablesReturnKeyAutomatically];
-}
-
-- (void)setEnablesReturnKeyAutomatically:(BOOL)value {
- [super setEnablesReturnKeyAutomatically:value];
-}
-
-- (BOOL)isSecureTextEntry {
- return [super isSecureTextEntry];
-}
-
-- (void)setSecureTextEntry:(BOOL)value {
- [super setSecureTextEntry:value];
-}
-
-@end

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -1,32 +0,0 @@
-require "SimpleAnnotation"
-
-waxClass{"SimpleMapController", UIViewController, protocols={"MKMapViewDelegate"}}
-
-function init(self)
- self.super:init()
- -- San Francisco, CA
- self.location = {
- lat=37.7749295,
- long=-122.4194155,
- }
-end
-
-function viewDidLoad(self)
- self.super:viewDidLoad()
-
- -- You need to ensure you add the MapKit framework for this to work
- -- (in Xcode, right-click "Frameworks" -> "Add" -> "Existing Frameworks".
- -- Then select "MapKit.framework" & hit OK).
- -- If you get an error like "Could not find protocol named 'MKAnnotation'",
- -- you've forgotten that step.
- self.map_view = MKMapView:initWithFrame(self:view():bounds())
- local region = MKCoordinateRegion(self.location.lat, self.location.long, 0.02, 0.02)
- local san_fran = SimpleAnnotation:initWithLatLong(self.location.lat, self.location.long)
- san_fran:setTitle('Downtown')
-
- self.map_view:setScrollEnabled(true)
- self.map_view:setRegion_animated(region, 1)
- self.map_view:addAnnotation(san_fran)
-
- self:view():insertSubview_atIndex(self.map_view, 0)
-end
@@ -2,17 +2,15 @@
// main.m
// MapKitExample
//
-// Created by Daniel Lindsley on 1/30/11.
-// Copyright __MyCompanyName__ 2010. All rights reserved.
+// Created by Corey on 3/5/11.
+// Copyright me 2011. All rights reserved.
//
// This where the magic happens!
// Wax doesn't use nibs to load the main view, everything is done within the
// AppDelegate.lua file
#import <UIKit/UIKit.h>
-#import "ProtocolLoader.h"
-
#import "wax.h"
#import "wax_http.h"
#import "wax_json.h"
@@ -21,7 +19,7 @@
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
- wax_startWithExtensions(luaopen_wax_http, luaopen_wax_json, luaopen_wax_xml, nil);
+ wax_start("AppDelegate", luaopen_wax_http, luaopen_wax_json, luaopen_wax_xml, nil);
int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");
[pool release];
@@ -4,6 +4,9 @@ function initWithLatLong(self, lat, long)
self.super:init()
self.lat = lat
self.long = long
+
+ -- These variables have underscores because they would have conflicted with
+ -- method names required by the MKAnnotation protocol.
self._title = 'Untitled'
self._subtitle = ''
end
@@ -0,0 +1,27 @@
+require "SimpleAnnotation"
+
+waxClass{"SimpleMapController", UIViewController, protocols={"MKMapViewDelegate"}}
+
+function init(self)
+ self.super:init()
+ -- San Francisco, CA
+ self.location = {
+ lat=37.7749295,
+ long=-122.4194155,
+ }
+end
+
+function viewDidLoad(self)
+ self.super:viewDidLoad()
+
+ self.mapView = MKMapView:initWithFrame(self:view():bounds())
+ local region = MKCoordinateRegion(self.location.lat, self.location.long, 0.02, 0.02)
+ local annotation = SimpleAnnotation:initWithLatLong(self.location.lat, self.location.long)
+ annotation:setTitle('Downtown')
+
+ self.mapView:setScrollEnabled(true)
+ self.mapView:setRegion_animated(region, 1)
+ self.mapView:addAnnotation(annotation)
+
+ self:view():insertSubview_atIndex(self.mapView, 0)
+end

0 comments on commit b1dd1ff

Please sign in to comment.