2016-08-16 1 views
0

Je construis une application où l'utilisateur doit être en mesure de sélectionner des photos de leur appareil photo rouleauionique obtenir toutes les vignettes de la caméra rouleau

Je sais que je peux utiliser la caméra cordova pluggin pour sélectionner une photo à temps ou le plugin cordova-imagePicker pour sélectionner plusieurs photos, mais je veux un je veux une sensation personnalisée où vous pouvez voir toutes les images dans l'application.

Sur Android, j'ai utilisé le plugin cordova-gallery-api, l'application se sentait un peu saccadée avec les images en taille réelle, mais fonctionne très bien avec les vignettes.

Quand j'ai essayé l'API Galerie sur IOS, avec le plug-in installé, la construction a échoué avec

** 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

Plus tôt j'ai trouvé le plugin cordova-camera-roll qui avait l'air de faire la même chose, mais seulement pour IOS. Je l'ai essayé, ça fonctionne; Cependant, il ne renvoie que les images en taille réelle qui semblent saccadées lors du défilement. Les deux plugins que j'ai essayés sont relativement vieux et je n'ai pas beaucoup d'expérience avec Objective-C, Si vous pouviez aider à modifier le plugin roll de caméra pour renvoyer des vignettes, ou obtenir le plugin de galerie pour travailler sur IOS, ou suggérer un autre plugin ce serait grandement apprécié.

PS. pour la facilité d'utilisation, la fonction Camera Roll

- (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]; 
    }]; 
    }]; 

} 

Merci

Répondre

0

Merci pour l'aide.

Le gallery-api a bien fonctionné tel quel, il me fallait juste pour activer les modules dans Xcode