在模拟器上运行时,我在Xamarin iOS项目上执行DZNEmptyDataset代码时遇到SIGSEV崩溃。我使用的是本机ios库DZNEmptyDataSet。
错误低于
Thread 0 Crashed:: tid_403 Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x0000000118a9cdd6 __pthread_kill + 10
1 libsystem_pthread.dylib 0x0000000118ad4787 pthread_kill + 90
2 libsystem_c.dylib 0x0000000118816fd7 abort + 129
3 com.johnamcruz.Balln 0x000000010be4192e mono_handle_native_sigsegv + 574 (mini-exceptions.c:2420)
4 com.johnamcruz.Balln 0x000000010bdbb24a mono_arch_handle_altstack_exception + 90 (exceptions-amd64.c:808)
5 com.johnamcruz.Balln 0x000000010be4eade mono_sigsegv_signal_handler + 446 (mini-runtime.c:2883)
6 libsystem_platform.dylib 0x0000000118abfbba _sigtramp + 26
7 ??? 000000000000000000 0 + 0
8 com.johnamcruz.Balln 0x000000010bd54c08 -[UIScrollView(DZNEmptyDataSet) dzn_reloadEmptyDataSet] + 33 (UIScrollView+EmptyDataSet.m:413)
9 com.johnamcruz.Balln 0x000000010bd5562d dzn_original_implementation + 150 (UIScrollView+EmptyDataSet.m:577)
10 com.apple.UIKit 0x0000000114cee302 -[UITableView layoutSubviews] + 34
我的代码如下。我在ViewDidAppear方法中刷新了tableview,并在ViewDidDisappear方法上将委托设置为null。
public async override void ViewWillAppear(bool animated)
{
base.ViewWillAppear(animated);
await RefreshGames();
FacebookLogin();
TableView.SetEmptyDataSetSource(new EmptyGameDataSource());
TableView.TableFooterView = new UIView();
}
public override void ViewWillDisappear(bool animated)
{
TableView.SetEmptyDataSetSource(null);
TableView.SetEmptyDataSetDelegate(null);
TableView.Source = null;
base.ViewWillDisappear(animated);
}
public async Task RefreshGames()
{
MTMBProgressHUD.ShowHUD(View, true);
var datasource = new GameDataSource(await gameLogic.GetAllGamesAsync());
datasource.RowDeleted += async (sender, e) =>
{
await gameLogic.DeleteGameAsync(e);
await RefreshGames();
};
TableView.Source = datasource;
MTMBProgressHUD.HideHUD(View, true);
}