从UIImagePickerController摄像头视图中推送viewController [英] Push a viewController from the UIImagePickerController camera view

查看:97
本文介绍了从UIImagePickerController摄像头视图中推送viewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个消息传递应用程序(类似于WhatsApp),用户可以相互发送文本和图像消息。

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.

这是我在两种情况下呈现 UIImagePickerController 的方式:

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

用户选择/拍照后,我正在推动 SendImageViewController 以全屏显示图像,并有一个实际发送图像的按钮。

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

当我按 SendImageViewController 从相机胶卷一切都很好。
问题是,当从相机拍摄图像时,我无法推送我的 SendImageViewController ,因为相机没有导航栏(我试过了)推送它,但我的 SendImageViewController 视图没有很好地显示)

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)

我该如何处理?

* 我不想解雇选择器,然后推送 SendImageViewController ,我希望 SendImageViewController 将被推到相机/相机胶卷的顶部,所以当我点击后退按钮时,我将返回到相机/相机胶卷视图。

* 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.

推荐答案

尝试显示如下导航栏:

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

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

这篇关于从UIImagePickerController摄像头视图中推送viewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆