Created
March 2, 2010 17:56
-
-
Save quique123/319720 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
#import <Foundation/Foundation.h> | |
@interface ViewController : UIViewController<UIImagePickerControllerDelegate, | |
UINavigationControllerDelegate> { | |
UIImagePickerController* imagePickerController; | |
IBOutlet UIImageView *imageView; | |
IBOutlet UIButton *setPic; | |
} | |
//@property (nonatomic,retain) IBOutlet UIButton *setPic; | |
//@property (nonatomic, retain) IBOutlet UIImageView *imageView; | |
@property (nonatomic,retain) UIImagePickerController *imagePickerController; | |
- (IBAction)setPic; | |
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info; | |
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "ViewController.h" | |
@implementation ViewController | |
@synthesize txtViewValue; //setPic,imageView; | |
@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]; | |
// LAST STEP WAS I ADDED THIS CODE TO SEE IF I COULD MAKE THE IMAGE SCROLLABLE BY USER | |
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; | |
[scrollView setContentSize:CGSizeMake(imageView.frame.size.width, imageView.frame.size.height)]; | |
[scrollView addSubview:imageView]; | |
[self.view addSubview:scrollView]; | |
} | |
- (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.allowsImageEditing = TRUE; | |
self.imagePickerController.delegate = self; | |
self.imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; | |
} | |
- (void)dealloc { | |
[super dealloc]; | |
[imagePickerController release]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment