CameraAppDelegate.h:----
#import <UIKit/UIKit.h>
@class CameraViewController;
@interface CameraAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
CameraViewController *viewController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet CameraViewController *viewController;
@end
CameraViewController.m:------
#import <UIKit/UIKit.h>
#import <AddressBookUI/AddressBookUI.h>
@interface CameraViewController : UIViewController<UIImagePickerControllerDelegate,ABPeoplePickerNavigationControllerDelegate> {
IBOutlet UIImageView *imgView;
}
-(IBAction)photosLibrary;
-(IBAction)showAdressBook;
@end
CameraViewController.h:-----
#import "CameraViewController.h"
@implementation CameraViewController
-(IBAction)photosLibrary{
UIImagePickerController *imageLibrary = [[UIImagePickerController alloc]init];
imageLibrary.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imageLibrary.delegate = self;
[self presentModalViewController:imageLibrary animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo{
[picker dismissModalViewControllerAnimated:YES];
imgView.image = image;
}
-(IBAction)showAdressBook{
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc]init];
picker.peoplePickerDelegate = self;
[self presentModalViewController:picker animated:YES];
}
- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker{
[peoplePicker dismissModalViewControllerAnimated:YES];
}
0 comments:
Post a Comment