Hi,
I am trying to asign actions to the action sheet button but nothing is happening. I have xcode 4.3. Following is my code. Please tell me where am I wrong. I want to chose the source of imagepicker from action sheet.
and then command line for action sheet
Thanx
I am trying to asign actions to the action sheet button but nothing is happening. I have xcode 4.3. Following is my code. Please tell me where am I wrong. I want to chose the source of imagepicker from action sheet.
Code:
- (IBAction)choosePhoto {
// Show an image picker to allow the user to choose a new photo.
UIActionSheet *actionSheet =
[[UIActionSheet alloc] initWithTitle:
@"Choose Source"
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:@"Take Photo", @"Choose Photo", nil];
[actionSheet showInView:self.view];
[actionSheet release];
}
and then command line for action sheet
Code:
- (void)actionSheet:(UIActionSheet *)actionSheet willDissmissWithButtonIndex:(NSInteger)buttonIndex
{
switch (buttonIndex)
{
case 0:
{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];
break;
}
case 1:
{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];
break;
}
}
}
Thanx