8

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.

Eyal
  • 10,777
  • 18
  • 78
  • 130

1 Answers1

15

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];
Olotiar
  • 3,225
  • 1
  • 18
  • 37
  • That is exactly what I wanted, thanks a lot :) Maybe u can check another question I had that is "After I got the image from the picker, How can I properly display it in a UIImageView?" here -http://stackoverflow.com/questions/11560711/landscape-mode-images-in-a-full-screen-uiimageview – Eyal Jul 22 '12 at 16:15
  • There was no issue with photo library but i was stuck with the camera view. Actually the only line doing magic is **[picker setNavigationBarHidden:NO animated:YES];** You saved my day ! thanks – Ammar Mujeeb Apr 13 '16 at 05:45