gpt4 book ai didi

iphone - 从 UIImagePickerController 相机 View 推送一个 viewController

转载 作者:可可西里 更新时间:2023-11-01 03:06:44 25 4
gpt4 key购买 nike

我正在开发一款消息传递应用程序(类似于 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 View 呈现不佳)

我该如何处理?

* 我不想关闭选取器然后推送 SendImageViewController,我希望将 SendImageViewController 推送到顶部相机/相机胶卷 View ,所以当我点击后退按钮时,我将返回到相机/相机胶卷 View 。

最佳答案

尝试像这样显示导航栏:

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

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

关于iphone - 从 UIImagePickerController 相机 View 推送一个 viewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11601526/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com