[英]ios UIImagePickerController delay switching to front camera in the first time
I have implemented to launch UIImagePickerController to capture picture. 我已实现启动UIImagePickerController来捕获图片。 At the first time, rear camera appear fast, then I switch to front camera, it responses very slowly. 第一次,后置摄像头出现很快,然后我切换到前置摄像头,它的响应速度非常慢。 It seems to take me nearly 15 seconds. 似乎花了我将近15秒。 I don't know why initing front camera so slow. 我不知道为什么启动前置摄像头这么慢。
Here my code 这是我的代码
UIImagePickerController * _picker = nil;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
_picker = [[[UIImagePickerController alloc] init] autorelease];
_picker.delegate = self;
_picker.allowsEditing = NO;
_picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:_picker animated:YES];
}
UPDATE: My device is iPad 2 (iOS 7.0), I also test Facebook app on my device, it responses immediately when I switch to front camera. 更新:我的设备是iPad 2(iOS 7.0),我也在设备上测试了Facebook应用程序,当我切换到前置摄像头时,它会立即响应。 When I test my app on Ipad mini (iOS 6.1.3), it works very well, this problem doesn't happen. 当我在Ipad mini(iOS 6.1.3)上测试我的应用程序时,它运行良好,不会发生此问题。 Can someone figure me out, it's little missing when initialize UIImagePickerController, I suppose. 有人可以弄清楚我吗,我想初始化UIImagePickerController时会少一点。
UPDATE 2: I wrote an another very simple project. 更新2:我写了另一个非常简单的项目。 It launches an UIImagePickerController immediately on viewDidLoad of the rootViewController and it works well, UIImagePickerController responses instantly when I switch to front camera. 它立即在rootViewController的viewDidLoad上启动UIImagePickerController,并且运行良好,当我切换到前置摄像头时,UIImagePickerController会立即响应。 Does anyone have idea for it? 有人对此有想法吗?
Do this on new thread would cancel the delay on open url. 在新线程上执行此操作将取消打开URL的延迟。 I bet it is the same delay. 我敢打赌,这是同样的延迟。 Note: Not yet tested on camera. 注意:尚未在相机上测试。
[NSThread detachNewThreadSelector:@selector(openbrowser_in_background:) toTarget:self withObject:Object];
- (void)openbrowser_in_background:(NSString *)url
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: url]];
}
And you might like to change the openURL to 您可能想要将openURL更改为
[self presentModalViewController:_picker animated:YES];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.