2016-08-16 5 views
0

は、私は、ユーザーが自分のカメラロールから写真を選択できるようにする必要があるアプリケーションを構築しています、私は私が1枚の写真を選択するためのplugginコルドバ・カメラを使用することができます知っているイオン得るすべてのサムネイルが

複数の写真を選択するためのcordova-imagePickerプラグインですが、アプリ内のすべての画像を見ることができるカスタム感が欲しいです。

Androidの場合、私はcordova-gallery-apiプラグインを使用していましたが、アプリはフルサイズの画像で少しばれているように感じましたが、サムネイルではうまく機能します。私がインストールされたプラグインで、IOS上のギャラリーのAPIを試してみました

は、ビルドは以前、私が唯一のIOSのために同じことをやって見 cordova-camera-rollプラグインを見つけ

** BUILD FAILED **

The following build commands failed: Ld build/emulator/.app/ normal i386 (1 failure) Error code 65 for command: xcodebuild with args: -xcconfig,/platforms/ios/cordova/build-debug.xcconfig,-project,.xcodeproj,ARCHS=i386,-target,,-configuration,Debug,-sdk,iphonesimulator,build,VALID_ARCHS=i386,CONFIGURATION_BUILD_DIR=/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/platforms/ios/build/sharedpch ERROR building one of the platforms: Error: /platforms/ios/cordova/build: Command failed with exit code 2 You may not have the required environment or OS to build this project Error: /platforms/ios/cordova/build: Command failed with exit code 2

で失敗しました。私はそれを試して、それは動作します。ただし、スクロールすると不安定に感じられるフルサイズの画像のみが返されます。

私が試したプラグインはどちらも比較的古いもので、Objective-Cの経験はあまりありません。サムネイルを返すようにカメラロールプラグインを変更したり、IOSで動作するようにギャラリープラグインを入手したりすると、別のプラグインをお勧めします。

PS。使用の容易なため 、カメラロール機能

- (void)getPhotos:(CDVInvokedUrlCommand*)command 
{ 

    // Grab the asset library 
    ALAssetsLibrary *library = [IonicCameraRoll defaultAssetsLibrary]; 

    // Run a background job 
    [self.commandDelegate runInBackground:^{ 

    // Enumerate all of the group saved photos, which is our Camera Roll on iOS 
    [library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) { 

     // When there are no more images, the group will be nil 
     if(group == nil) { 

     // Send a null response to indicate the end of photostreaming 
     CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:nil]; 
     [pluginResult setKeepCallbackAsBool:YES]; 
     [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; 

     } else { 

     // Enumarate this group of images 

     [group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) { 

      NSDictionary *urls = [result valueForProperty:ALAssetPropertyURLs]; 

      [urls enumerateKeysAndObjectsUsingBlock:^(id key, NSURL *obj, BOOL *stop) { 

      // Send the URL for this asset back to the JS callback 
      CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:obj.absoluteString]; 
      [pluginResult setKeepCallbackAsBool:YES]; 
      [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; 

      }]; 
     }]; 
     } 
    } failureBlock:^(NSError *error) { 
     // Ruh-roh, something bad happened. 
     CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:error.localizedDescription]; 
     [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; 
    }]; 
    }]; 

} 

おかげで助けを

答えて

0

感謝。

gallery-apiはそのままで、Xcodeでモジュールを有効にするだけです。

関連する問題