UIImagePickerController相机源问题
好的,这是我编写的用于在相机源中显示 UIImagePickerController 的代码。我刚刚在属性的标头中声明了 myPhotopicker 并保留它。综合在主代码文件中。然后调用选择器,我编写了下面的代码:
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
if (myPhotopicker==nil) {
myPhotopicker = [[UIImagePickerController alloc] init];
myPhotopicker.delegate = self;
}// create once!
myPhotopicker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:myPhotopicker animated:NO];
}
调用它时,应用程序发生了一些奇怪的事情。
有时,当后台运行多个应用程序时(iPhone4),应用程序会无法加载相机并导致应用程序崩溃。虽然它可以毫无问题地加载CameraRoll/PhotoAlbums。
如果相机视图能够加载(当后台运行的应用程序较少时),点击相机视图上的“取消”按钮会导致应用程序自行重新启动(其中快速显示 Default.png 图像,然后返回)到主页 - 就像我们启动应用程序时一样)。
我一直在试图解决这个问题,但不知道该怎么做...请帮助..谢谢。
Ok here is the code that I wrote to display the UIImagePickerController in the camera source. I just declared the myPhotopicker in the header for the property and retain it. Synthesized it in the main code file. Then calling the picker I wrote the code below:
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
if (myPhotopicker==nil) {
myPhotopicker = [[UIImagePickerController alloc] init];
myPhotopicker.delegate = self;
}// create once!
myPhotopicker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:myPhotopicker animated:NO];
}
Upon calling it, there are a few things that is weird happening to the app.
Sometimes, when there are many apps running in the background (iPhone4), the app would fail to load the camera and crash the app. Though it will load CameraRoll/PhotoAlbums without problem.
If the camera view is able to load (when there are less apps running in the background), tapping the Cancel button on the camera view results in the app rebooting itself (where the Default.png image is shown quickly, and back to the main page - like when we started the app).
I have been trying to figure out this problem, but not sure what to do... pls help.. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是图像选择器控件的完整代码,也可以尝试找到解决方案。这里。
http://www.icodeblog.com/2009/07/28/getting-images-from-the-iphone-photo-library-or-camera-using-uiimagepickercontroller/
问候,
Shyam Parmar
here is the complete code of image pickercontrol try too find solu. here.
http://www.icodeblog.com/2009/07/28/getting-images-from-the-iphone-photo-library-or-camera-using-uiimagepickercontroller/
Regards,
Shyam Parmar
尝试每次创建和释放,而不是“创建一次”逻辑。
您还应该实现委托,以便在模式视图控制器被关闭时从视图中删除它(如果您还没有这样做)。
您还应该检查当前类是否符合 UINavigationConrollerDelegate 协议。
Rather than your 'create once' logic try creating and releasing each time.
You should also implement the delegate to remove the modal view controller from view when it is dismissed (if you haven't already).
You should also check that the current class conforms to the UINavigationConrollerDelegate protocol.