我有一个基于UITabBarController
的应用。它有3个标签。在第一个标签中(默认启动应用时),系统会显示UIImagePickerController
以选择相册。但问题是:TabBar
将涵盖UIImagePickerController
。如何在UIImagePickerController
内插入UITabBarController
?非常感谢帮助。这是我的代码:
//第一个标签的viewController.m
- (void)loadView
{
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
[self presentModalViewController:imagePicker animated:NO];
[imagePicker release];
}
再次尝试后,我按如下方式修改了一些代码,可以显示标签栏,但无法点击。怎么办?
- (void)loadView
{
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:imagePicker animated:NO];
CGRect rect = CGRectMake(imagePicker.view.frame.origin.x,
imagePicker.view.frame.origin.y,
imagePicker.view.frame.size.width,
imagePicker.view.frame.size.height-self.tabBarController.tabBar.frame.size.height);
imagePicker.view.frame = rect;
[imagePicker.view addSubview:self.tabBarController.tabBar];
[imagePicker release];
}
答案 0 :(得分:0)
不要将其显示为模态视图控制器,只需将其视图添加到当前视图控制器:
- (void)loadView {
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
[self.view addSubview:imagePicker.view];
[imagePicker release];
}
如果需要,请不要忘记对框架进行调整。