Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customizing Section indexes in UITableView in iphone application

  • Does any one have tried to customize default section index displayed in UITableView.
  • I want to modify the appearance of UITableView SectionIndex.
  • Is it possible to customize it ?
  • Is there any delegate methods available for this ?
  • What delegate methods should I use - if above question's answer is yes?
  • I have uploaded an image for the sample check it out.
like image 328
Sagar Kothari Avatar asked Apr 15 '10 07:04

Sagar Kothari


3 Answers

It doesn't look like standard index view is customizable.

In my application I just created custom index view instead of standard one. Basically all you need to do here is track touch position in that view and scroll UITableView accordingly. You may also need to add some visual effects - change view's background color on touch and highlight current section title.

like image 181
Vladimir Avatar answered Nov 03 '22 23:11

Vladimir


https://github.com/Hyabusa/CMIndexBar

Use this plugin from Hyabusa. Simple replacment for UITableView Index that allows setting of colors

CMIndexBar *indexBar = [[CMIndexBar alloc] initWithFrame:CGRectMake(self.view.frame.size.width-35, 10.0, 28.0, self.view.frame.size.height-20)];
[indexBar setIndexes:[NSMutableArray arrayWithObjects:@"A",@"B",@"C",@"D",@"E",@"F",@"G", nil]];
[self.view addSubview:indexBar];
[indexBar release];

Delegate

- (void)indexSelectionDidChange:(CMIndexBar *)IndexBar:(int)index:(NSString*)title;
like image 31
Emile Khattar Avatar answered Nov 03 '22 22:11

Emile Khattar


Swift version:

tableView.sectionIndexBackgroundColor = UIColor.clearColor() //iOS7+
tableView.sectionIndexTrackingBackgroundColor = UIColor.clearColor() //iOS6+
tableView.sectionIndexColor = UIColor.redColor() //iOS6+

To customize the index view height (UITableViewStylePlain style only):

tableView.sectionIndexMinimumDisplayRowCount = 15
like image 22
SoftDesigner Avatar answered Nov 03 '22 23:11

SoftDesigner