开发者

Click multiple images using UIImagePickerController in iPhone

I'm not able to take multiple images using the camera. Could you direct me to some code showing how to recall the camera multiple times? Thanks in advance.

Code used:

-(void) invokeCamera{ 
//Invoke View for Camera 
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { 
imagePicker = [[UIImagePickerController alloc] init]; 
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; imagePicker.showsCameraControls = YES; 
 imagePicker.delegate = self; 
[self presentModalViewController:imagePicker animated:YES]; 
[imagePicker release]; 
imagePicker = nil; 
} 
else { 
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Camera Unavailable" message:@"Requires a camera to take pictures" delegate:nil cancelButtonTitle:@"Continue" otherButtonTitles:nil]; 
[alert show]; 
[alert release]; 
}

}

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

 uploadImage = [info objectForKey:@"UIImagePickerControllerOriginalImage"]; 
[uploadImage retain]; 
indicatorView = [[UIView alloc] initWithFrame:CGRectMake(75, 155, 170, 170)]; indicatorView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5]; indicatorView.clipsToBounds = YES; //indicatorView.layer.cornerRadius = 10.0;

objIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; objIndicatorView.frame = CGRectMake(65, 40, objIndicatorView.bounds.size.width, objIndicatorView.bounds.size.height); 
[indicatorView addSubview:objIndicatorView];

indicatorLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 115, 130, 22)]; indicatorLabel.backgroundColor = [UIColor clearColor];
 indicatorLabel.textColor = [UIColor whiteColor]; 
indicatorLabel.adjustsFontSizeToFitWidth = YES; 
indicatorLabel.textAlignment = UITextAlignmentCenter; 
indicatorLabel.text = @"Uploading Image..."; 
[indicatorView addSubview:indicatorLabel];

 [picker.view addSubview:indicatorView];
 [picker.view bringSubviewToFront:indicatorView]; 
[objIndicatorView startAnimating];

 [self performSelector:@selector(closeImagePicker) withObject:nil afterDelay:0.1];
 }

(void)closeImagePicker{

[self form开发者_开发知识库Request: uploadImage];

if (objIndicatorView != nil) 
{ 
[objIndicatorView stopAnimating];
 [objIndicatorView removeFromSuperview]; 
[objIndicatorView release]; 
objIndicatorView = nil; 
} 
indicatorView.hidden = YES;

if ([respPhotoUpload.msg isEqualToString: @"Image Uploaded"])
 {

 [self invokeCamera];
 }
else 
 { 
  [self dismissModalViewControllerAnimated:YES]; 
 }
}


if ([respPhotoUpload.msg isEqualToString: @"Image Uploaded"])
 {
 [self dismissModalViewControllerAnimated:NO];
 [self invokeCamera];
 }
else 
 { 
  [self dismissModalViewControllerAnimated:YES]; 
 }

I am not sure. Use your own button to take picture then dismiss the camera once you are done with it and then present again

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜