Push a viewController from the UIImagePickerController camera view

耗尽温柔 提交于 2019-12-05 21:35:11

问题


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.


回答1:


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];


来源:https://stackoverflow.com/questions/11601526/push-a-viewcontroller-from-the-uiimagepickercontroller-camera-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!