我有一个非常随机的问题。我有一个通过Local Notifications启动的应用程序,当它启动时我会提供一个模态视图控制器,它是我的图像选择器。在代码中,我强迫它使用前置摄像头,我在iPod Touch第4代和iPhone 4上进行了测试,他们都有一个随机的问题,它切换到后置摄像头。这是一些代码:
[self.oViewController loadUserinfo:userInfo];
[self.navController presentModalViewController:self.oViewController.imagePickerController animated:YES];
-(void)loadUserinfo:(NSDictionary *)userI{
NSLog(@"OverLayViewController: loadUserinfo");
self.userInfo = userI;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSLog(@"check for front facing camera...");
if([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceFront]){
NSLog(@"found! setting to front-facing");
self.flipCam.hidden = NO;
[self.imagePickerController setCameraDevice:UIImagePickerControllerCameraDeviceFront];
[defaults setBool:YES forKey:@"usingFrontFacingCamera"];
}
else{
NSLog(@"not found");
self.flipCam.hidden = YES;
[defaults setBool:NO forKey:@"usingFrontFacingCamera"];
}
//runtime settings
self.shotNum = [[self.userInfo objectForKey:@"picsPerShoot"] intValue];
//reset counter label
self.countDownLabel.hidden = NO;
[self.countDownLabel setText:@"5"];
}
所以在我调用presentModalViewController之前,我检查前置摄像头并调用setCameraDevice,我的控制台正在吐出正确的消息:
检查前置摄像头...... 发现前置设置
我在这里遗漏了什么吗?
提前致谢!