当前位置:编程学习 > wap >>

iPhone开发 调用摄像头进行拍照等操作

-(IBAction)addPicEvent

{

    UIImagePickerControllerSourceType sourceType=UIImagePickerControllerSourceTypeCamera;

    if (![UIImagePickerControllerisSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {

        sourceType=UIImagePickerControllerSourceTypePhotoLibrary;

    }

    UIImagePickerController * picker = [[UIImagePickerControlleralloc]init];

    picker.delegate=self;

    picker.allowsEditing=YES;

    picker.sourceType=sourceType;

    [selfpresentModalViewController:picker animated:YES];

}

-(void)saveImage:(UIImage*)image

{

    NSLog(@"保存");

}

-(void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

{

    [picker dismissModalViewControllerAnimated:YES];

    UIImage * image=[info objectForKey:UIImagePickerControllerEditedImage];

    [selfperformSelector:@selector(saveImage:) withObject:image afterDelay:0.5];

}

-(void)imagePickerControllerDIdCancel:(UIImagePickerController*)picker

{

    [picker dismissModalViewControllerAnimated:YES];

}

 

摘自 凡娃软件
补充:移动开发 , IOS ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,