Am neuen in Xamarin geworfen Forms und ich versuche, JSON
Daten sowie Bilder von Web in eine ListView
zurückzuholen, aber ich lese über ATShttps://developer.xamarin.com/guides/ios/platform_features/introduction_to_ios9/ats/ und ich versuchte, um es in unten zu implementieren ist der Screenshot, aber ich bekomme immer noch System.Net.WebException
.Xamarin Forms- (IOS) System.Net.WebException wurde
Mein Bild
Dies ist der Fehler, den ich bekommen:
$exception {System.Net.WebException:
The resource could not be loaded because
the App Transport Security policy …}
System.Net.WebException
Dies ist meine Klasse SeiteOnlineStreaming.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;
}
}
meine Xaml Seite:
<?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>
Bitte mir Jungen helfen, warum diese auf IOS ist.
i hinzugefügt ** NSAllowsArbitraryLoadsInWebContent ** plus ** NSAllowsArbitraryLoads ** und i gesetzt alles wahr, aber noch ist es die gleiche Ausnahme zu bringen, bitte helfen Sie mir, wo ich falsch sind. –
entfernen Sie alle verwandten Schlüssel zu ATS und verwenden Sie die vorgeschlagene Antwort. – KKRocks
ja @KKRocks, ich entfernte alle von ihnen und ich verwendete Ihre Lösung, aber immer noch den gleichen Fehler, bin verwirrt :( –