升级到MT 4.0后,索引表格视图不显示

Jas*_*son 5 uitableview xamarin.ios ios

升级到MT 4.0后,之前在右侧边框上显示索引的TableView不再有效.tableview仍然显示在部分中并且正常工作,但索引未显示.

我在UITableViewSource中定义了这三个方法,这三个方法似乎都在工作:

public override string[] SectionIndexTitles(UITableView tableView)

public override int SectionFor(UITableView tableView, string Title, int atIndex)

public override string TitleForHeader(UITableView tableView, int section)
Run Code Online (Sandbox Code Playgroud)

还有其他人有这个问题吗?这是MT 4.0的错误吗?

Jas*_*son 2

这是一个已知的错误

看来 UITableView 没有保留返回的数组,您可以使用以下方法来解决此问题,同时我们进一步调查它:

NSArray array;

[Export ("sectionIndexTitlesForTableView:")]
public NSArray SectionTitles (UITableView tableview)
{   
    if (array == null) {
        string[] titles = new string[RowsInSection(tableview, 0)];
        for (int index = 0; index < titles.Length; index++)
            titles[index] = index.ToString();

        array = NSArray.FromStrings (titles);
    }

    return array;
}
Run Code Online (Sandbox Code Playgroud)