我在网上看到了很多这样的帖子(旧帖子),但似乎没有什么对我有用.我正在尝试从字符串中生成QR码并将其显示在应用程序中.
这就是我在开始时所拥有的
qrCode = new ZXingBarcodeImageView
{
BarcodeFormat = BarcodeFormat.QR_CODE,
BarcodeOptions = new QrCodeEncodingOptions
{
Height = 50,
Width = 50
},
BarcodeValue = codeValue,
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalOptions = LayoutOptions.CenterAndExpand
};
Run Code Online (Sandbox Code Playgroud)
这适用于Android,但在IOS设备上它根本没有渲染.所以在研究之后我试着这样做:
Image qrCode;
if (Device.OS == TargetPlatform.iOS)
{
var writer = new BarcodeWriter
{
Format = BarcodeFormat.QR_CODE,
Options = new ZXing.Common.EncodingOptions
{
Width = 50,
Height = 50
}
};
var b = writer.Write(codeValue);
qrCode = new Image
{
Aspect = Aspect.AspectFill,
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalOptions = LayoutOptions.CenterAndExpand, …Run Code Online (Sandbox Code Playgroud) I'm developing an app with xamarin.forms which hase to play some sound. For that is created an interface 'IAudioPlayer'
namespace ClassLibrary.AudioPlayer
{
public interface IAudioPlayer
{
void PlayAudio(string filename);
}
}
Run Code Online (Sandbox Code Playgroud)
And in the droid project i've got the implementation like this:
using System;
using Android.Media;
using Xamarin.Forms;
[assembly: Dependency(typeof(myApp.Droid.AudioPlayer_Android))]
namespace myApp.Droid
{
public class AudioPlayer_Android : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity, ClassLibrary.AudioPlayer.IAudioPlayer, AudioTrack.IOnPlaybackPositionUpdateListener
{
public void PlayAudio(string filename)
{
var player = new MediaPlayer();
var fd = global::Android.App.Application.Context.Assets.OpenFd(filename);
player.Prepared += (s, e) => …Run Code Online (Sandbox Code Playgroud)