How do I create a modal dialog with customisable button choices just like the "take picture or video" | "choose existing" dialog on the iPhone? Those buttons aren't normal UIButton's and I'm sure they aren't hand crafted for every app out there.
It sounds like you want to use a combination of UIActionSheet and UIImagePickerController. This code shows a popup that lets the user choose to take a photo or choose an existing one, then the UIImagePickerController pretty much does everything else:
- (IBAction)handleUploadPhotoTouch:(id)sender {
    mediaPicker = [[UIImagePickerController alloc] init];
    [mediaPicker setDelegate:self];
    mediaPicker.allowsEditing = YES;
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
        UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil
                                                                 delegate:self
                                                        cancelButtonTitle:@"Cancel"
                                                   destructiveButtonTitle:nil
                                                        otherButtonTitles:@"Take photo", @"Choose Existing", nil];
        [actionSheet showInView:self.view];
    } else {
        mediaPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;     
        [self presentModalViewController:mediaPicker animated:YES];
    }
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (buttonIndex == 0) {
        mediaPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
    } else if (buttonIndex == 1) {
        mediaPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;     
    }
    [self presentModalViewController:mediaPicker animated:YES];
    [actionSheet release];
}
NOTE: This assumes you have a member variable "mediaPicker" which keeps a reference to the UIImagePickerController
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With