2016-08-16 22 views
0

나는 사용자가 자신의 카메라 롤에서 사진을 선택 할 수 있어야 응용 프로그램을 짓고 있어요 나는이에 하나 개의 사진을 선택하는 pluggin 코르도바 - 카메라를 사용할 수 있습니다 알고이온 얻을 모든 축소판

여러 사진을 선택하는 cordova-imagePicker 플러그인을 사용하고 싶지만 앱의 모든 이미지를 볼 수있는 사용자 정의 느낌을 원합니다.

안드로이드에서 나는 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에서 작동하도록 할 수 있다면, 또는 다른 플러그인을 제안하면 크게 감사하겠습니다.

추신. 사용하기 쉬운을위한 , 카메라 롤 기능

- (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에서 모듈을 활성화해야합니다.