2012-05-15 30 views

回答

1

是的,有一種方法可以做到這一點。我建議你下載iAd Producer。安裝完成後,.dmg磁盤中會有一個「額外」目錄。有一些有用的例子,其中之一是攝像頭的訪問和圖像處理。

https://developer.apple.com/iad/iadproducer/

在任何情況下,這是一個按鈕小片段,將觸發相機和將顯示在圖像視圖中拍攝的照片:

var button = this.viewController.outlets.button; 

變種圖像= this.viewController .outlets.image;

this.onViewTouchUpInside =函數(事件){

// Access the camera object 
var camera = window.ad.camera; 

// if the API is unavailable, the object will be null 
if (!camera) { 
    if (iAd.Device.iOSVersionLessThan('5.0')) { 
     alert('The Camera API is not available in iOS ' + iAd.Device.iOS_VERSION); 
    } 
    else { 
     alert('The Camera API could not be accessed.'); 
    } 

    return; 
} 

// Reason from the app to explain the user 
var reason = 'The app would like to take a photo'; 
camera.present(reason); 

};

如果(window.ADCamera){

this.viewController.addEventListener(ADCamera.ADCameraUserTookPicture, function (event) { 

    // access the camera object 
    var camera = window.ad.camera; 

    // access the new picture 
    var newPicture = camera.currentPictureURI; 

    // set the image view's image to the new picture 
    image.image = new iAd.Image(newPicture);   


}, false); 


this.viewController.addEventListener(ADCamera.ADCameraUserCanceledPicture, function (event) { 
}, false); 

}

祝你好運!

相關問題