开发者

Why do I have an empty (but working) table index band in UITableView?

Using MonoTouch to develop my very first iPhone application for a customer, I've overridden the UITableViewDataSource.SectionIndexTitles function to provide a string[] array with what I thought would make the letters in the vertical band.

Currently I'm facing a working index band but without any characters displayed:

Why do I have an empty (but working) table index band in UITableView?

(I do think the UITableViewDataSource.SectionIndexTitles has the native counterpart sectionIndexTitlesForTableView).

My question:

Can someone give me a hint on what I mig开发者_开发百科ht be doing wrong here?

I do not have all A-Z characters but some characters missing, maybe this could be an issue?


This is a bug in MonoTouch. A workaround is to create a new method in your table source class and decorate it with the Export attribute, passing the native ObjC method to override (sectionIndexTitlesForTableView:):

string[] sectionIndexArray;
//..
[Export ("sectionIndexTitlesForTableView:")]
public NSArray SectionTitles (UITableView tableview)
{                   
    return NSArray.FromStrings(sectionIndexArray);
}


I would like to get back to my point...

can you show the way you build the returned value for sectionIndexTitlesForTableView? I just tried with SimpleSectionedTableView sample app from apple http://developer.apple.com/library/ios/#samplecode/TableViewSuite/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007318

with this code:

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
    NSMutableArray *a = [[NSMutableArray alloc]initWithCapacity:10];
    for (int i = 0; i<[regions count]; i++) {
        Region *r = [regions objectAtIndex:i];
        NSString *s = r.name;
        [a addObject:s];
    }
    NSArray *ax = [NSArray arrayWithArray:a];
    return ax;


}

And everything works fine...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜