【问题标题】:Select image iphone simulator using phonegap camera api使用phonegap相机api选择图像iphone模拟器
【发布时间】:2010-03-26 12:18:33
【问题描述】:

我是 Xcode 和 iPhone 应用程序的新手。我想从 iPhone(相机或库)中选择一个图像并通过 ajax 发送到 php。

我正在使用 phonegap 框架,Xcode iPhone SDK 版本 3.1.x。单击按钮时,它会调用参数为 0 或 1 的函数,但不会初始化相机或显示库。

我使用了this link中的代码

它在调试控制台中显示此错误:

2010-03-25 23:36:02.337 PhoneGap[7433:207] Camera.getPicture: Camera not available.

模拟器 dsnt 有摄像头,但照片(来自图书馆)也不能正常工作!

可能是什么错误? 我认为在使用navigator.camera.getPicture 时首先检查摄像头,如果没有中断并显示错误~?

【问题讨论】:

    标签: javascript iphone api camera cordova


    【解决方案1】:

    用于在 iphone 模拟器中使用照片库。您必须符合委托 UINavigationControllerDelegate、UIImagePickerControllerDelegate 和 alloc pickerview 并在其上设置委托,然后检查

    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
                [self presentModalViewController:imagePickerView animated:YES];
            }
    

    【讨论】:

      【解决方案2】:

      我不知道您如何使用该框架。但 UIImagePickerController 是我用来从 iPhone 库或设备相机中选择照片的类。您需要做的就是将其设置为显示库:

      UIImagePickerController *picker = [[UIImagePickerController alloc] init];
      //set your delegate and other properties...
      picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
      

      picker.sourceType = UIImagePickerControllerSourceTypeCamera;
      

      你应该检查一下。 干杯

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-07-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-04-08
        • 1970-01-01
        相关资源
        最近更新 更多