2
我使用xamarin.forms來做一個應用程序,但由於某種原因, ,我改變這個頁面後,我把圖像變大了,並添加了一些網格,gesturerecognizer停止只在iPhone工作,在Android它正常工作...凸輪有人看到這個代碼中的問題?因爲到目前爲止,我不能。 由於我需要的模板,我正在編程創建一個頁面。GestureRecognizer不能只在ios中工作xamarin.forms
private void CriaTela()
{
int row = 0;
int column = 0;
gridtextura.RowSpacing = 5;
gridtextura.ColumnSpacing = 15;
lstCategorias = lstCategorias.OrderBy(o => o.nome).ToList();
foreach (var item in lstCategorias)
{
Grid GridContent = new Grid
{
RowSpacing = 0,
//BackgroundColor = Color.Pink,
VerticalOptions = LayoutOptions.FillAndExpand,
RowDefinitions =
{
new RowDefinition { Height = new GridLength(8, GridUnitType.Star) },
new RowDefinition { Height = new GridLength(2, GridUnitType.Star) }
}
};
var textura = new CachedImage();
textura.Source = "texturaCateg";
textura.HorizontalOptions = LayoutOptions.FillAndExpand;
textura.VerticalOptions = LayoutOptions.FillAndExpand;
textura.Aspect = Aspect.Fill;
GridContent.BindingContext = item;
Grid boxColorView = new Grid
{
RowSpacing = 0,
// BackgroundColor = Color.Pink,
VerticalOptions = LayoutOptions.FillAndExpand,
RowDefinitions =
{
new RowDefinition { Height = new GridLength(2, GridUnitType.Star) },
new RowDefinition { Height = new GridLength(8, GridUnitType.Star) }
}
};
boxColorView.Children.Add(new BoxView { Color = Color.FromHex(item.corFundo), VerticalOptions = LayoutOptions.FillAndExpand }, 0, 1);
boxColorView.Children.Add(textura, 0, 1);
boxColorView.Children.Add(new BoxView { VerticalOptions = LayoutOptions.FillAndExpand }, 0, 0);
gridtextura.Children.Add(boxColorView, column, row);
gridtextura.Children.Add(GridContent, column, row);
//Qual categoria foi escolhida?
var CliqueCategoria = new TapGestureRecognizer();
CliqueCategoria.Tapped += (s, e) =>
{
CriaLoading();
var stacklayout = s as Grid;
categoriaEscolhida = (Categorias)stacklayout.BindingContext;
ChamaProdutos();
};
GridContent.GestureRecognizers.Add(CliqueCategoria);
GridContent.BackgroundColor = Color.Green;
if (item.imagem != null && item.imagem != "")
{
int initIndex = item.imagem.IndexOf(',');
string image = "";
image = item.imagem.Substring(initIndex + 1);
try
{
GridContent.Children.Add(new CachedImage { Source = ImageSource.FromStream(() => new MemoryStream(Convert.FromBase64String(image))), VerticalOptions = LayoutOptions.FillAndExpand }, 0, 0);
}
catch (Exception e)
{
GridContent.Children.Add(new CachedImage { Source = "error.png", VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.Fill, HeightRequest = 50, WidthRequest = 50 }, 0, 0);
}
}
GridContent.Children.Add(new Label { Text = item.nome, TextColor = Color.FromHex(item.corTexto), FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label)), FontAttributes = FontAttributes.Bold, HorizontalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.CenterAndExpand }, 0, 1);
if (column == 0)
{
column = 1;
}
else
{
column = 0;
row++;
}
}
}
----------------編輯-------------------
我知道有點更多關於這個問題...因爲現在我有一個圖像是一個按鈕...它正在工作...但現在,它已經超過了其他圖像,然後它不再工作了...但它已經結束了圖像...這是我在這裏發佈的這段代碼的相同案例...我有一個網格在其他..在相同的位置和寬度和長度...和頂部網格不接收水龍頭
某些子元素有可能捕獲水龍頭並且不讓它們通過父網格。嘗試在'GridContent'子控件上設置'InputTranparent = true'。 – Ada
更多細節在這裏:https://developer.xamarin.com/api/property/Xamarin.Forms.VisualElement.InputTransparent/ – Ada
所有的childreen應該得到InputTranparent = true,對吧? –