如何避免在重新加载单元格时uitableview单元格刷新闪烁
我使用monotouch.dialog开发了一个PrivateMsg对话屏幕。但是当我重新装入电池时,电池会闪烁,如何避免呢 添加新pm msg accross 2步骤:1。追加元素单元格:State.Insert(msg正在发送)=>2。重新加载元素单元格状态:State.Updated(msg send successed) 请查找附件:屏幕记录文件和源代码:如何避免在重新加载单元格时uitableview单元格刷新闪烁,uitableview,monotouch.dialog,Uitableview,Monotouch.dialog,我使用monotouch.dialog开发了一个PrivateMsg对话屏幕。但是当我重新装入电池时,电池会闪烁,如何避免呢 添加新pm msg accross 2步骤:1。追加元素单元格:State.Insert(msg正在发送)=>2。重新加载元素单元格状态:State.Updated(msg send successed) 请查找附件:屏幕记录文件和源代码: void HandleOnPMChanged(object sender, PMChangedEventArgs e)
void HandleOnPMChanged(object sender, PMChangedEventArgs e)
{
if (e.PMSID != this.mPMSession.PMSID)
return;
this.BeginInvokeOnMainThread(() =>
{
if (e. State == State.Insert) //step1
{
element = this.GetNewPMElement(itemData);
pmSection.Add(element);
this.ScrollToBottomRow();
} else if (e.State == State.Update && e.PM != null) //step2
{
var element = FindElement(e.PM.Guid.GetHashCode());
if (element != null)
{
var indexPaths = new NSIndexPath [] { element.IndexPath };
this.TableView.ReloadRows(indexPaths, UITableViewRowAnimation.None); //this line will flicker
//remark: this.ScrollToBottomRow();
}
}
else if (e. State == State.Insert)
{
element = this.GetNewPMElement(itemData);
pmSection.Add(element);
this.ScrollToBottomRow(); //step1
}
});
}
public void ScrollToBottomRow()
{
try
{
if (pmSection.Count < 1)
return;
NSIndexPath ndxPath = pmSection[pmSection.Count - 1].IndexPath;
if (ndxPath != null)
this.TableView.ScrollToRow(ndxPath, UITableViewScrollPosition.Bottom, false); //Bottom, false);
}
catch (Exception ex)
{
Util.ReportMsg("PMDVC ScrollToBottomRow Exception:", ex.Message);
}
}
void HandleOnPMChanged(对象发送方,pmchangedventargs e)
{
if(e.PMSID!=此.mPMSession.PMSID)
返回;
this.beginInvokeMainThread(()=>
{
if(e.State==State.Insert)//步骤1
{
element=this.GetNewPMElement(itemData);
pmSection.Add(元素);
this.ScrollToBottomRow();
}else if(e.State==State.Update&&e.PM!=null)//步骤2
{
var element=FindElement(e.PM.Guid.GetHashCode());
if(元素!=null)
{
var IndexPath=new nsindepath[]{element.indepath};
this.TableView.ReloadRows(indexPaths,UITableViewRowAnimation.None);//此行将闪烁
//备注:此.ScrollToBottomRow();
}
}
else if(e.State==State.Insert)
{
element=this.GetNewPMElement(itemData);
pmSection.Add(元素);
this.ScrollToBottomRow();//步骤1
}
});
}
公共无效滚动条ToBottomRow()
{
尝试
{
如果(pmSection.Count<1)
返回;
nsindepath ndxPath=pmSection[pmSection.Count-1].indepath;
if(ndxPath!=null)
this.TableView.ScrollToRow(ndxPath,UITableViewScrollPosition.Bottom,false);//Bottom,false);
}
捕获(例外情况除外)
{
Util.ReportMsg(“PMDVC ScrollToBottomRow异常:”,ex.Message);
}
}
问题已修复
EstimatedHeight返回的值大于实际值