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];
}
posted @ 2012-03-16 23:05  与时俱进  阅读(722)  评论(0编辑  收藏  举报
友情链接:同里老宅院民居客栈