Permalink
Browse files

Add toolbar and button to take a picture

  • Loading branch information...
afh committed Apr 19, 2011
1 parent c412a75 commit 7b9a032ba95a0ab29be83287859318dd07e7be19
Showing with 134 additions and 311 deletions.
  1. +1 −1 OnTheSpot/OnTheSpot-Info.plist
  2. +5 −1 OnTheSpot/RootViewController.h
  3. +32 −0 OnTheSpot/RootViewController.m
  4. +96 −309 OnTheSpot/en.lproj/MainWindow.xib
@@ -5,7 +5,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
- <string>${PRODUCT_NAME}</string>
+ <string>On The Spot</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
@@ -8,9 +8,13 @@
#import <UIKit/UIKit.h>
-@interface RootViewController : UITableViewController {
+@interface RootViewController : UITableViewController
+< UINavigationControllerDelegate
+, UIImagePickerControllerDelegate
+> {
}
+- (IBAction)takePicture;
@end
@@ -8,6 +8,11 @@
#import "RootViewController.h"
+@interface RootViewController()
+- (void)storeImage:(UIImage*)anImage withMetaData:(NSDictionary*)metaData;
+@end
+
+
@implementation RootViewController
- (void)viewDidLoad
@@ -141,4 +146,31 @@ - (void)dealloc
[super dealloc];
}
+- (IBAction)takePicture
+{
+ UIImagePickerController *vc = [[UIImagePickerController alloc] init];
+ vc.delegate = self;
+ if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
+ vc.sourceType = UIImagePickerControllerSourceTypeCamera;
+ }
+ [self.navigationController presentModalViewController:vc animated:YES];
+ [vc release];
+}
+
+#pragma mark -
+#pragma mark UIImagePickerControllerDelegate Methods
+- (void)imagePickerController:(UIImagePickerController *)picker
+didFinishPickingMediaWithInfo:(NSDictionary *)info
+{
+ [self.navigationController dismissModalViewControllerAnimated:YES];
+
+ NSDictionary* metaData = (NSDictionary*)[info valueForKey:UIImagePickerControllerMediaMetadata];
+ UIImage* image = (UIImage*)[info valueForKey:UIImagePickerControllerOriginalImage];
+ [self storeImage:image withMetaData:metaData];
+}
+
+- (void)storeImage:(UIImage*)anImage withMetaData:(NSDictionary*)metaData
+{
+ // store image in CouchDB
+}
@end
Oops, something went wrong.

0 comments on commit 7b9a032

Please sign in to comment.