作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我想在 UItableView 右侧显示的部分索引中包装单词。
问题是,如果单词长度增加,部分索引宽度也会增加,表格 View 单元格内容 View 大小会减小。我不想显示部分索引数组对象的子字符串。因为我想显示整个单词我必须将其包装的部分。
-(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;
}
sectionIndextitle 方法返回的数组中的对象很长,我想换行。
有人知道怎么做吗?
最佳答案
您只能创建自己的“部分索引 View ”作为自定义 UIView
而且很容易做到这一点
只需计算你的tableview的高度,计算你的sections的数量
然后在上面画上你的章节标题
- (void)drawRect:(CGRect)rect
然后检测触摸事件
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
计算你触摸的部分,然后调用tableview方法
- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated;
然后把它放在你的 tableview 上,轻松完成!
关于iphone - 是否可以将单词包装在 UITableViewSectionIndex 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10328561/
如果用户单击UITableView,我想更改其部分索引的颜色。 我可以在初始化 tableview 和任何其他状态时设置 sectionIndexColor 和 sectionIndexTrackin
我想在 UItableView 右侧显示的部分索引中包装单词。 问题是,如果单词长度增加,部分索引宽度也会增加,表格 View 单元格内容 View 大小会减小。我不想显示部分索引数组对象的子字符串。
我是一名优秀的程序员,十分优秀!