2017-07-25 4 views

Antwort

1

Wie Swapnil Patwa sagt im Kommentar, können Sie den Benutzer mit einem ActionSheet fragen:

public showActionSheet() { 
    let actionSheet = this.actionSheetCtrl.create({ 
     buttons: [{ 
     text: 'Load from gallery', 
     handler:() => {this.loadImage(this.camera.PictureSourceType.PHOTOLIBRARY);} 
     },{ 
     text: 'Take a photo', 
     handler:() => {this.loadImage(this.camera.PictureSourceType.CAMERA);} 
     },{ 
     text: 'Cancel', 
     role: 'cancel' 
     }] 
    }); 
    actionSheet.present(); 
    } 

    private loadImage(selectedSourceType:number){ 
    let cameraOptions: CameraOptions = { 
     sourceType: selectedSourceType, 
     destinationType: this.camera.DestinationType.DATA_URL, 
     quality: 100, 
     encodingType: this.camera.EncodingType.JPEG, 
     mediaType: this.camera.MediaType.PICTURE, 
     correctOrientation: true, 
    } 
    this.camera.getPicture(cameraOptions).then((imageData) => { 
     if(imageData!=null){ 
     // Do with the image data what you want. 
     } 
    }); 
    } 
+0

Jetzt benutze ich actionSheet, aber zB in der 'Viber' App kannst du eine Kamera auswählen und zur Fotogalerie wechseln. Ich würde das gerne so organisieren. – wstudiokiwi

+0

Kamera ist ein natives Plugin, ich glaube nicht, dass es Ihnen erlaubt, das zu tun, im Doc von Ionic 2 finde ich diese Option nicht. –