是否可以在UITableViewSectionIndex中包装单词?

War*_*olf 8 iphone objective-c uitableview ios

我想在UItableView的右侧显示部分索引中的单词.

问题是,如果字长增加,节索引宽度也增加,表视图单元格内容视图大小减小.我不想显示节索引数组对象的子字符串.因为我想在节中显示整个单词必须包装它.

-(NSArray*) sectionIndexTitlesForTableView:(UITableView *)tableView
{
    NSMutableArray *array = [[NSMutableArray alloc] init];

    for (int i = 0; i <[keys count]; i++) {
        NSString *str = [self.keys objectAtIndex:i];
           [array addObject:str];
    }

    NSArray *a =[NSArray arrayWithArray:array];
    [array release];
    return a;
}
Run Code Online (Sandbox Code Playgroud)

数组中的对象返回sectionIndextitle方法是冗长的,我想包装该单词.

谁知道怎么做?

在此输入图像描述

Dav*_*e.B 0

看来您的答案是否定的,但以下内容应该可以解决您问题背后的问题。

\n\n

我会在 UITableViewDelegate 协议上使用这个函数来代替 tableView:viewForHeaderInSection: 。更多信息可以在UITableViewDelegate Docs 的文档中找到。注意 \xe2\x80\x93 tableView:heightForHeaderInSection: 也必须实现。这种函数组合将允许您返回一个带有 UILabel 子视图的视图,该子视图的 numberOfLines 设置为 0,即根据需要设置任意数量,并将文本设置为您需要的任何值。

\n