如何在iPhone中使用UIImagePickerController和UITabBar

如何在iPhone中使用UIImagePickerController和UITabBar,iphone,Iphone,我正在应用程序中使用TabBarController。在选项卡栏的一个视图中,我使用UIImagePickerController拾取图像 当我添加选择器时,如下所示 UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; imagePicker.delegate = self; imagePicker.editing = YES; [self presentModalViewContro

我正在应用程序中使用TabBarController。在选项卡栏的一个视图中,我使用
UIImagePickerController
拾取图像

当我添加选择器时,如下所示

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];

imagePicker.delegate = self;

imagePicker.editing = YES;

[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];

它添加了选择器,但在选择照片时,底部的栏中有“选择”和“取消”按钮,隐藏在我的选项卡栏下。如何解决这个问题。

我没有看到这个问题-我有一个应用程序,它同时使用
UIAbbar
UIImagePickerController
,并且选项卡栏不会遮挡图像选择器

在我的视图控制器中(它是
uitabar
的视图控制器之一),我正在创建这样的图像选择器:

self.imagePicker = [[[UIImagePickerController alloc] init] autorelease];
imagePicker.allowsImageEditing = NO;
imagePicker.delegate = self;
[self presentModalViewController:imagePicker animated:YES];

看起来与您的代码非常相似,只是我将图像选择器设置为保留属性。您的选项卡栏设置正确吗?视图控制器是否包含在
myTabBar.viewControllers
数组中?

问题在于您使用self作为显示模式屏幕的导航控制器。因此,选项卡栏导航控制器不知道模式屏幕应该填满整个屏幕。由于UIImagePickerController无法将自身调整为较小的尺寸,因此必须使用选项卡栏导航控制器打开显示模式视图

我使用以下代码从选项卡栏中显示的导航控制器显示UIImagePickerController:

[self.navigationController presentModalViewController:picker animated:YES];
使用self.navigationController而不是self作为显示UIImagePickerController的对象为我做到了这一点。

这对我很有用:

picker.delegate = currentClassViewController;

[tabBarController presentModalViewController:picker animated:YES];

让您的picker caller类拥有或访问您的
UITabController
变量和
presentModalViewController
对您的
tabBarController

是。我有一个选项卡栏,它的第一个控制器是firstViewCtonroller,它有一个navigationController。使用这个navigationController,我切换到不同的视图,在其中一个视图中,我使用上面的代码。但是选项卡栏并没有隐藏在imagePicker的视图下。嘿,在使用UIImageController时,您是否也面临内存泄漏。嘿,您可能不允许用户编辑图像。如果允许,下一个视图将与底部的选项卡栏一起出现。很好,我没有这样做。我会尝试一下,看看标签栏是否出现。为什么这个答案被接受?这里面的问题没有解决办法。还是我错过了什么?