0

I have an UIAlertView which has an Button. By pressing that button I need to load a Camera controller(Image Picker) above the UIAlertView. Pressing cancel in ImagePicker will go back to UIAlertView of Previous view.

Any Help is Greatly appreciated. Thanks in Advance.

{

    UIButton *aStartTimer = [[UIButton alloc]initWithFrame:CGRectMake(90, 170, 45, 45)];
    [aStartTimer setImage:[UIImage imageNamed:@"timer.png"] forState:UIControlStateNormal];

    [alertView addSubview:aStartTimer];
}

Thanks in advance

Rakesh Bhatt
  • 4,606
  • 3
  • 25
  • 38
Dilip Rajkumar
  • 7,006
  • 6
  • 60
  • 76
  • Check the answer I have posted below – stack2012 Jul 14 '11 at 05:05
  • Before adding this code u should have declared an imagePickerViewcontroller in the name "picker" (which I have used in this code) Then for the alert view u need to add the UIAlertViewDelegate to ur viewcontroller . – stack2012 Jul 14 '11 at 05:07
  • Thank you for your kind reply booleanBoy i did not get an notification for this question. I have actually changed the view as button. Thank you once again for your answer. – Dilip Rajkumar Oct 18 '11 at 08:55
  • Thank you very much for your answer I will follow it. – Dilip Rajkumar Oct 20 '11 at 08:16

1 Answers1

1
        UIAlertView * alertAddImage = [[UIAlertView alloc] init];
        [alertAddImage setDelegate:self];
        [alertAddImage setTitle:@"Add Images"];

        [alertAddImage addButtonWithTitle:@"Take a New Picture"];
        [alertAddImage addButtonWithTitle:@"Cancel"];
        [alertAddImage setNeedsLayout];
        [alertAddImage show];
        [alertAddImage release];

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0)
    [self imageFromCamera];
}

-(void)imageFromCamera{
 imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
 [self presentModalViewController:imgPicker animated:YES];
}
stack2012
  • 2,146
  • 2
  • 16
  • 23