8

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

当用户想要发送图像时,他可以从相机胶卷中选择一张,也可以用相机拍摄一张。

这就是我介绍这UIImagePickerController两种情况的方式:

- (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全屏显示图像并有一个按钮来实际发送图像。

这就是我推动它的方式:

- (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视图呈现不佳)

我该如何处理?

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

4

1 回答 1

15

尝试像这样显示导航栏:

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

[picker setNavigationBarHidden:NO animated:YES];
[picker pushViewController:vc animated:YES];
于 2012-07-22T15:49:27.347 回答