如何实时重新加载 UITableView
How to reload UITableView in real time
我有 UITableView
控制器,导航栏右侧有一个同步按钮。当用户第一次进入此屏幕时,table 为空。当我点击同步按钮时,我想:
调用我的函数获取新数据
立即重新加载视图中的数据(不必返回或到另一个视图来刷新)
现在,table 似乎什么都没有发生,除非我返回一个屏幕,然后再回来。这是我的代码:
public override viewdidload(){
base.viewdidload();
MyTable.Source = new MyListSource (items, this);
this.NavigationItem.SetRightBarButtonItem(new UIBarButtonItem(UIBarButtonSystemItem.Action, syncMe), true);
}
public async void syncMe(){
await getData();
MyTable.ReloadData();
}
试试这个:
public override viewdidload()
{
base.viewdidload();
MyTable.Source = new MyListSource (items, this);
this.NavigationItem.SetRightBarButtonItem(new UIBarButtonItem(UIBarButtonSystemItem.Action, syncMe), true);
}
public async void syncMe()
{
items = await getData();
MyTable.Source = new MyListSource (items, this);
MyTable.ReloadData();
}
我有 UITableView
控制器,导航栏右侧有一个同步按钮。当用户第一次进入此屏幕时,table 为空。当我点击同步按钮时,我想:
调用我的函数获取新数据
立即重新加载视图中的数据(不必返回或到另一个视图来刷新)
现在,table 似乎什么都没有发生,除非我返回一个屏幕,然后再回来。这是我的代码:
public override viewdidload(){
base.viewdidload();
MyTable.Source = new MyListSource (items, this);
this.NavigationItem.SetRightBarButtonItem(new UIBarButtonItem(UIBarButtonSystemItem.Action, syncMe), true);
}
public async void syncMe(){
await getData();
MyTable.ReloadData();
}
试试这个:
public override viewdidload()
{
base.viewdidload();
MyTable.Source = new MyListSource (items, this);
this.NavigationItem.SetRightBarButtonItem(new UIBarButtonItem(UIBarButtonSystemItem.Action, syncMe), true);
}
public async void syncMe()
{
items = await getData();
MyTable.Source = new MyListSource (items, this);
MyTable.ReloadData();
}