【发布时间】:2017-06-02 22:25:18
【问题描述】:
我是 Xamarin Forms 的新手,我正在尝试将 JSONdata 以及来自网络的图像检索到 ListView 但是,我读到了 ATS https://developer.xamarin.com/guides/ios/platform_features/introduction_to_ios9/ats/ 和我试图在info.plist 中实现它,下面是屏幕截图,但我仍然得到System.Net.WebException。
我的形象
这是我得到的错误:
$exception {System.Net.WebException:
The resource could not be loaded because
the App Transport Security policy …}
System.Net.WebException
这是我的班级页面 OnlineStreaming.xaml.cs
public partial class OnlineStreaming : ContentPage
{
private HttpClient _client = new HttpClient();
public ObservableCollection<Adverts> adverts;
private const string Url = "http://eamobiledirectory.com/cooperp/Mobile/Mobileapi.aspx?Action=Featured&Country=Uganda";
private const string BaseImageUrl = "http://eamobiledirectory.com/cooperp/Images/app_images/";
public OnlineStreaming()
{
InitializeComponent();
}
protected override async void OnAppearing()
{
var content = await _client.GetStringAsync(Url);
var adv = JsonConvert.DeserializeObject<List<Adverts>>(content);
adverts = new ObservableCollection<Adverts>(adv);
foreach (var item in adverts)
{
//some coding
adverts.Add(new Adverts
{
company_name = item.company_name
,
office_photo = BaseImageUrl + item.office_photo
});
//Debug.WriteLine("Output is here :" + item.company_name);
}
listViewTest.ItemsSource = adverts;
}
}
我的 Xaml 页面:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
Title="Online Streaming"
x:Class="BBSTV.OnlineStreaming">
<ListView x:Name="listViewTest">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout>
<Image Aspect="Fill" Source="{Binding office_photo}"/>
<Label TextColor="Gray" Text="{Binding company_name}"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ContentPage>
请帮帮我,为什么这是在 IOS 上。
【问题讨论】:
标签: c# ios xamarin.ios xamarin.forms