我無法從AlexRainman製作CarouselView控件。該控件在Android上呈現良好,但不在iOS上。我的項目是iOS和Android的Xamarin PCL項目,目前正在爲Visual Studio 2017 for macOS工作。並堅持這一點,並不知道如何解決這個錯誤。任何幫助,將不勝感激。從AlexRainman的CarouselView不在iOS上渲染,在Android上很好。 Xamarin.Forms
我的內容頁:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="PelotaJara.BookingUserPage"
xmlns:controls="clr-namespace:CarouselView.FormsPlugin.Abstractions;assembly=CarouselView.FormsPlugin.Abstractions"
>
<controls:CarouselViewControl x:Name="carousel" IndicatorsTintColor="Gray" ShowIndicators="True"
CurrentPageIndicatorTintColor="Black" Orientation="Horizontal" InterPageSpacing="10"
VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand" AnimateTransition="true" IsSwipingEnabled="true">
<controls:CarouselViewControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30*" />
<RowDefinition Height="50*" />
<RowDefinition Height="20*" />
</Grid.RowDefinitions>
<Image Grid.Row="0" VerticalOptions="Start" HorizontalOptions="CenterAndExpand" Source="{Binding Image}"/>
<Label Grid.Row="0" Text="Cancha Iluminada" TextColor="White" HorizontalOptions="Center" VerticalOptions="End"/>
<Button Grid.Row="2" Text="Reservar" BackgroundColor="Red" HorizontalOptions="Fill" VerticalOptions="Center" TextColor="White"/>
</Grid>
</DataTemplate>
</controls:CarouselViewControl.ItemTemplate>
</controls:CarouselViewControl>
隱藏代碼:
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class BookingUserPage : ContentPage
{
ObservableCollection<CarouselModel> model { get; set; }
public BookingUserPage()
{
InitializeComponent();
model = new ObservableCollection<CarouselModel>();
carousel.ItemsSource = model;
model.Add(new CarouselModel("http://seattlerats.org/wp-content/uploads/2015/03/Soccer-Field-Night.jpg"));
model.Add(new CarouselModel("http://seattlerats.org/wp-content/uploads/2015/03/Soccer-Field-Night.jpg"));
model.Add(new CarouselModel("http://seattlerats.org/wp-content/uploads/2015/03/Soccer-Field-Night.jpg"));
}
}
public class CarouselModel
{
public CarouselModel(string imageString)
{
Image = imageString;
}
private string _image;
public string Image
{
get { return _image; }
set { _image = value; }
}
}
的Appdelegate.cs:
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
ServicePointManager
.ServerCertificateValidationCallback +=
(sender, cert, chain, sslPolicyErrors) => true;
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
CarouselViewRenderer.Init();
return base.FinishedLaunching(app, options);
}
最後,我MainActivity.cs :
[Activity(Label = "PelotaJara", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
ServicePointManager
.ServerCertificateValidationCallback +=
(sender, cert, chain, sslPolicyErrors) => true;
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
CarouselViewRenderer.Init();
LoadApplication(new App());
}
}
你可以在GitHb上打開一個問題 –
你在iOS上遇到的問題是什麼? – AXE
@ user3096081你有沒有找到任何解決方案。 – Kishore