任何人都可以提供鏈接/示例代碼使用Acr.XamForms中的相機和圖庫訪問Xamarin.Forms中的Nuget?在Xamarin.Forms中使用Acr.XamForms Nuget的相機和圖庫訪問的示例代碼
我從here的代碼,但我想用Acr.XamForms的NuGet包在我的PCL執行功能[不包括在設備特定項目]
提前感謝!
任何人都可以提供鏈接/示例代碼使用Acr.XamForms中的相機和圖庫訪問Xamarin.Forms中的Nuget?在Xamarin.Forms中使用Acr.XamForms Nuget的相機和圖庫訪問的示例代碼
我從here的代碼,但我想用Acr.XamForms的NuGet包在我的PCL執行功能[不包括在設備特定項目]
提前感謝!
我花的時間與ACR樣品和仍然沒有想通了這一切完全是如何結合在一起的。所以我最終從頭開始編寫App.cs文件中的所有內容,並通過試用/錯誤提出了這個非常簡單的解決方案,適用於iOS和Android。它允許您從圖庫中獲取圖像或拍攝照片,完成後會顯示照片。希望這會幫助某人節省幾個小時。
我也想向那些努力爲社區創造出色的圖書館的人提出請求:請提供超級簡單的使用示例。不要創建一個展示的一切資料庫一個精心製作的樣本...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using Xamarin.Forms;
using Acr.XamForms.Mobile.Media;
namespace photoSimpleTest
{
public class App : Application
{
MediaPicker mPick = new MediaPicker();
Image ShowPic;
public App()
{
var showGalleryButton = new Button {
Text="Show Gallery"
};
showGalleryButton.Clicked += ShowGallery;
var takePictureButton = new Button
{
Text = "Take Picture"
};
takePictureButton.Clicked += TakePicture;
ShowPic = new Image();
MainPage = new ContentPage
{
Content = new StackLayout
{
VerticalOptions = LayoutOptions.Center,
Children = {
showGalleryButton,
takePictureButton,
ShowPic
}
}
};
}
public async void ShowGallery(object s, EventArgs a)
{
if (!mPick.IsPhotoGalleryAvailable)
Debug.WriteLine("Photo Gallery is unavailable");
else
{
var result = await mPick.PickPhoto();
PhotoReceived(result);
}
}
public async void TakePicture(object s, EventArgs a)
{
if (!mPick.IsCameraAvailable)
Debug.WriteLine("Camera is not available");
else
{
var opt = new CameraOptions { };
var result = await mPick.TakePhoto(opt);
PhotoReceived(result);
}
}
private void PhotoReceived(IMediaFile file)
{
if (file == null)
Debug.WriteLine("Photo Cancelled");
else
ShowPic.Source = ImageSource.FromFile(file.Path);
}
}
}
我確實有這個項目,但它包含在一個單一的項目這麼多東西,這麼多的類都包含這樣一直在尋找的簡單的解決辦法代碼相同。 – 2014-09-29 09:48:40