I want to wrap the word in section index displaying on the right side of the UItableView.
The problem is that, if the word length increases the section index width also increases and table view cell content view size reduces.And I do not want to display substring of section index array object.Since I want to display whole word in the section i have to wrap it.
-(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;
}
object in the array return by sectionIndextitle method is lengthy and I want to wrap the word.
Any one knows how it can be done?
you can only create your own "section index view" as a custom UIView
and it's eazy to do that
just calc the height of your tableview , calc the count of your sections
then draw your section title on it in
- (void)drawRect:(CGRect)rect
then detect the touch event
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
calc which section you touched , then call the tableview method
- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated;
then put it on your tableview, eazy done!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With