码迷,mamicode.com
首页 > 移动开发 > 详细

默认手机照相功能

时间:2014-05-18 19:30:14      阅读:284      评论:0      收藏:0      [点我收藏+]

标签:c   a   cti   代码   type   for   

下面是主要代码:

- (void) addPicEvent 

    //先设定sourceType为相机,然后判断相机是否可用(ipod)没相机,不可用将sourceType设定为相片库 
    UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera; 
    if (![UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) { 
        sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
    }   
    UIImagePickerController *picker = [[UIImagePickerController alloc] init]; 
    picker.delegate = self; 
    picker.allowsEditing = YES; 
    picker.sourceType = sourceType; 
    [self presentModalViewController:picker animated:YES]; 
    [picker release]; 

- (void)saveImage:(UIImage *)image { 
    NSLog(@"保存"); 

#pragma mark – 
#pragma mark Camera View Delegate Methods 
- (void)imagePickerController:(UIImagePickerController *)picker 
didFinishPickingMediaWithInfo:(NSDictionary *)info { 
    [picker dismissModalViewControllerAnimated:YES]; 
    UIImage *image = [[info objectForKey:UIImagePickerControllerEditedImage] retain]; 
    [self performSelector:@selector(saveImage:) 
               withObject:image 
               afterDelay:0.5]; 

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { 
    [picker dismissModalViewControllerAnimated:YES]; 
}

默认手机照相功能,布布扣,bubuko.com

默认手机照相功能

标签:c   a   cti   代码   type   for   

原文地址:http://www.cnblogs.com/AbelChen1991/p/3732732.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!