Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Xamarin表单应用程序中,如何在每次单击按钮时将图像旋转90度?_Xamarin_Xamarin.forms_Xamarin.android_Xamarin.ios - Fatal编程技术网

在Xamarin表单应用程序中,如何在每次单击按钮时将图像旋转90度?

在Xamarin表单应用程序中,如何在每次单击按钮时将图像旋转90度?,xamarin,xamarin.forms,xamarin.android,xamarin.ios,Xamarin,Xamarin.forms,Xamarin.android,Xamarin.ios,我正在使用插件。媒体从我的图库中选择照片。我想为用户提供一个选项,当他们点击图像时,可以旋转图像 使用“旋转”属性时,可以旋转图像一次。但是,每次用户单击按钮时,我都会将其旋转90度 if (!CrossMedia.Current.IsPickPhotoSupported) { await DisplayAlert("Photos Not Supported", "Permission not granted

我正在使用插件。媒体从我的图库中选择照片。我想为用户提供一个选项,当他们点击图像时,可以旋转图像

使用“旋转”属性时,可以旋转图像一次。但是,每次用户单击按钮时,我都会将其旋转90度

if (!CrossMedia.Current.IsPickPhotoSupported)
                {
                    await  DisplayAlert("Photos Not Supported", "Permission not granted 
                                    to photos", "OK");
                    return;
                }
                var file =   Plugin.Media.CrossMedia.Current.PickPhotoAsync(new 
                                  Plugin.Media.Abstractions.PickMediaOptions
                {
                    PhotoSize = Plugin.Media.Abstractions.PhotoSize.Small
                });
                if (file == null)
                    return;
                imageProfile.Source = ImageSource.FromStream(() =>
                {
                    var stream = file.Result.GetStream();
                    file.Result.Dispose();
                    return stream;
                });

public void rotateButton_Clicked(object sender, Event args e) {

           imageProfile.RotateX(90);
           // This event allows me to rotate the image only once.
}
int angle = 0;

public void rotateButton_Clicked(object sender, Event args e) {

    angle += 90;
    imageProfile.RotateX(angle);
}