我正在尝试将UIImagePickerController
添加到rootviewcontroller
作为subview
,以便相机显示在主应用区域内,而不是叠加层。
这是我的代码:
-(void)cameraSetup{
CGRect bottomBarFrame = CGRectMake(0, self.view.frame.size.height-UA_BOTTOM_BAR_HEIGHT, self.view.frame.size.width, UA_BOTTOM_BAR_HEIGHT);
self.bottomNavBar = [[BottomNavBar alloc] initWithFrame:bottomBarFrame leftIcon:UA_ICON_PHOTOLIBRARY withFrame:CGRectMake(0, 0, 45, 22.5) centerIcon:UA_ICON_TAKE_PHOTO withFrame:CGRectMake(0, 0, 90, 45)];
//create a new image picker instance
picker = [[UIImagePickerController alloc]init];
picker.delegate = self;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
//set source to video!
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
//hide all controls
picker.showsCameraControls = NO;
picker.navigationBarHidden = NO;
picker.toolbarHidden = YES;
picker.editing = NO;
//make the video preview full size
//picker.wantsFullScreenLayout = YES;
picker.cameraViewTransform = CGAffineTransformScale(picker.cameraViewTransform,1, 1);
[picker.view addSubview:self.bottomNavBar];
picker.view.frame=CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-(UA_TOP_WHITE+UA_TOP_WHITE-bottomBarFrame.size.height));
[self.view addSubview:picker.view];
[picker viewWillAppear:YES];
[picker viewDidAppear:YES];
}else{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Test Text" message:@"Camera is Not Availble" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil];
[alert show];
}
}
即使我将选择器的框架设置为不是全屏,它总是显示为全屏。有没有办法摆脱这种行为?或者是否有其他选项可以在选择器上显示我的BottomNavBar
?
答案 0 :(得分:-3)
UIImagePickerController
适用于应用程序需要访问系统资源的情况,例如相机,甚至用户照片库。由于他们UIImagePickerController
以受控方式启用系统访问,因此很明显您无法对其进行自定义。