【发布时间】:2012-07-22 15:26:20
【问题描述】:
我正在开发一种消息应用程序(类似于 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 会被推送到相机/相机胶卷的顶部,所以当我点击返回按钮,我将返回相机/相机胶卷视图。
【问题讨论】:
标签: iphone objective-c ios uiimagepickercontroller