Skip to content

Instantly share code, notes, and snippets.

@quique123
Created February 3, 2010 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quique123/294097 to your computer and use it in GitHub Desktop.
Save quique123/294097 to your computer and use it in GitHub Desktop.
//
// Created by Marcio Valenzuela on 12/4/09.
// Copyright Personal 2009. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "AppViewController.h"
@interface AppDelegate : NSObject <UIApplicationDelegate,UIImagePickerControllerDelegate> {
UIWindow *window;
AppViewController *viewController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet AppViewController *viewController;
@end
//
// Created by Marcio Valenzuela on 12/4/09.
// Copyright Personal 2009. All rights reserved.
//
#import "AppDelegate.h"
#import "AppViewController.h"
@implementation AppDelegate
@synthesize window;
@synthesize viewController;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Override point for customization after application launch
[window addSubview:viewController.view];
[window makeKeyAndVisible];
}
- (void)dealloc {
[window release];
[viewController release];
[super dealloc];
}
@end
//
// Created by Marcio Valenzuela on 12/4/09.
// Copyright 2009 Personal. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface AppViewController : UIViewController<UIImagePickerControllerDelegate,
UINavigationControllerDelegate> {
UIImagePickerController* imagePickerController;
IBOutlet UIImageView *imageView;
IBOutlet UIButton *setPic;
}
@property (nonatomic,retain) UIImagePickerController *imagePickerController;
- (IBAction)setPic;
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info;
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker;
@end
//
// Created by Marcio Valenzuela on 12/4/09.
// Copyright 2009 Personal. All rights reserved.
//
#import "AppViewController.h"
@implementation AppViewController
@synthesize imagePickerController;
- (IBAction)setPic{
[self presentModalViewController:self.imagePickerController animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary*)info{
imageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
// Dismiss the image selection and close the program
[picker dismissModalViewControllerAnimated:YES];
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
self.imagePickerController = [[UIImagePickerController alloc] init];
self.imagePickerController.delegate = self;
self.imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
- (void)dealloc {
[super dealloc];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment