uitableviewmonotouch.dialog

how to avoid uitableview cell refresh flicker when reload cell


I used the monotouch.dialog to develop one PrivateMsg talk screen. But when I reload the cell , the cell flicker, how to avoid it ?

add new pm msg accross 2 step: 1. append a element cell: State.Insert(msg is sending)=> 2. reload the element cell status: State.Updated(msg send sucessced)

Pls find the attachment:screen recording file and the source code:

enter image description here

    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);
        }
    }

Solution

  • issue has been fixed.

    EstimatedHeight return bigger than actual value.