HomePage
がStackLayout
の内部にListView
のXamarinフォームを使用してアプリケーションを作成しています。グループ化は、私のリストで有効になっていると、以下のように、それは私のXAMLで宣言されています。ListViewのItemSourceを設定すると、iOSでクラッシュし、Androidで正常に動作します。
<ListView x:Name="listsListView" IsGroupingEnabled="True" GroupDisplayBinding="{Binding groupName}"
HasUnevenRows="True" GroupShortNameBinding="{Binding ShortName}">
<ListView.GroupHeaderTemplate>
<DataTemplate>
<ViewCell>
<Label Text="{Binding groupName}"/>
</ViewCell>
</DataTemplate>
</ListView.GroupHeaderTemplate>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Label Text="{Binding itemName}"/>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
私の後ろに私のコードでは
は私ListView
の内容を設定します。ここでは
//ListGroup extends List<Item> and gives the name for the group header
group1 = new ListGroup("Group 1");
group2 = new ListGroup("Group 2");
//I then add a few items to my ListGroups
groupedLists = new List<ListGroup>();
groupedLists.Add(childListGroup);
groupedLists.Add(listsListGroup);
listsListView.ItemsSource = groupedLists;
は私の実装ですListGroup
:
public class ListGroup : List<Item>
{
public string groupName { get; set; }
public string ShortName { get; set; }
public ListGroup(string Name)
{
this.groupName = Name;
ShortName = "";
}
}
私はコードdちょっと変わって、ListView
のItemSource
を設定すると最後の行でエラーが発生します。奇妙なことはすべてがAndroidで完璧に動作することです。しかし、iOSの中に、私が手: "は*キャッチされない例外によりにアプリを終了 'NSInvalidArgumentException'、理由: '* - [NSPlaceholderString initWithUTF8String:]:NULLのCString'"
私はこれを取得しています、なぜ誰もが知っていますiOSでエラーが発生しましたか?私はしばらくの間Androidをやってきましたが、iOSにはまったく新しいものです。
Date/Time: 2017-03-23T01:58:34Z
Launch Time: 2017-03-23T01:55:34Z
OS Version: Mac OS X 10.2 (16D32)
Report Version: 104
Exception Type: SIGABRT
Exception Codes: #0 at 0x11a944dd6
Crashed Thread: 0
Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSPlaceholderString initWithUTF8String:]: NULL cString'
Last Exception Backtrace:
0 CoreFoundation 0x0000000118af9d33 0x118a03000 + 1010995
1 libobjc.A.dylib 0x0000000119a4421e 0x119a3f000 + 21022
2 CoreFoundation 0x0000000118b632b5 0x118a03000 + 1442485
3 Foundation 0x00000001105a2624 0x11058c000 + 91684
4 MyApp.iOS 0x000000010dcd29a0 0x10d9f1000 + 3021216
5 MyApp.iOS 0x000000010dcdc73a 0x10d9f1000 + 3061562
6 MyApp.iOS 0x000000010dcd568a 0x10d9f1000 + 3032714
7 MyApp.iOS 0x000000010dcdbdbd 0x10d9f1000 + 3059133
8 MyApp.iOS 0x000000010dcdd171 0x10d9f1000 + 3064177
9 UIKit 0x000000010eacff71 0x10e96e000 + 1449841
10 MyApp.iOS 0x000000010dcdd2f9 0x10d9f1000 + 3064569
11 ??? 0x00000001321d76ae 0x0 + 0
'ListGroup'の実装方法も共有できますか? – mindOfAi
はい私はそれを2番目に編集します – cvanbeek