简体   繁体   中英

Push a viewController from the UIImagePickerController camera view

I'm developing a messaging app (something like WhatsApp), users can send text and image messages to one another.

when user wants to send an image, he can choose one from the camera roll or he can take one with the camera.

This is how I present the UIImagePickerController for both cases:

- (void)handleTakePhoto
{
    UIImagePickerController *ipc = [[UIImagePickerController alloc] init];

    ipc.delegate = self;
    ipc.sourceType = UIImagePickerControllerSourceTypeCamera;

    [self presentModalViewController:ipc animated:YES];
    [ipc release];
}

- (void)handleChooseFromLibrary
{
    UIImagePickerController *ipc = [[UIImagePickerController alloc] init];
    ipc.delegate = self;
    ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

    NSString *desired = (NSString *)kUTTypeImage;
    if ([[UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary] containsObject:desired]) {
        ipc.mediaTypes = [NSArray arrayWithObject:desired];
    }

    [self presentModalViewController:ipc animated:YES];
    [ipc release];
}

After the user choose/take a picture I'm pushing a SendImageViewController that shows the image in full screen and has a button to actually send the image.

This is how I push it:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];


    SendImageViewController *sivc = [[SendImageViewController alloc] initWithImage:image
                                                                          delegate:self];
    [picker pushViewController:sivc animated:YES];
    [sivc release];
}  

When I push SendImageViewController from the camera roll everything works great. The problem is that I can't push my SendImageViewController when the image is taken from the camera, because the camera doesn't have a navigation bar (I tried to push it but my SendImageViewController view doesn't presented well)

How can I deal with this?

* I don't want to dismiss the picker and then push the SendImageViewController , I want that the SendImageViewController will be pushed on top of the camera/camera roll, so when I tap the back button I'll back to the camera/camera roll view.

Try showing the navigation bar like this :

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide];

[picker setNavigationBarHidden:NO animated:YES];
[picker pushViewController:vc animated:YES];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM