Setting section indexes in UITableView in iphone application

  • Someone tried to set the default partition index displayed in a UITableView.
  • I want to change the look of the UITableView SectionIndex.
  • Can I customize it?
  • Are there any delegate methods available for this?
  • What delegate methods should I use - if the answer to the question above is yes?
  • I have uploaded an image for the sample check it out.
+11
objective-c iphone cocoa-touch uitableview
Apr 15 '10 at 7:30
source share
5 answers

It doesn't seem like the standard index view is configurable.

In my application, I simply created my own index instead of the standard one. Basically all you have to do is track the position of the touch in that view and scroll through the UITableView accordingly. You may also need to add some visual effects - change the background color of the view when touched and highlight the current section title.

+12
Apr 15 2018-10-10T00:
source share

https://github.com/Hyabusa/CMIndexBar

Use this plugin from Hyabusa. A simple replacement for the UITableView index, which allows you to set 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; 
+1
Feb 06 '13 at 18:53
source share

Quick version:

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

To adjust the height of the index view ( UITableViewStylePlain style only):

 tableView.sectionIndexMinimumDisplayRowCount = 15 
+1
Oct 27 '15 at 21:38
source share
 tableView.tintColor = UIColor.redColor(); 

will do it for you

0
Aug 02 '15 at 2:36
source share

In fact, there is no official Apple for Apple. And Apple may reject your application if you do. If you just want to customize the indexBar, then the library below can help you.

You can use Swift's custom CollectionIndexTools library (iOS 8+), which you can customize.

https://github.com/ReverseScale/CollectionIndexTools

Here's an example snippet for CollectionIndexTools

 lazy var collectionViewIndex: CollectionViewIndex = { let collectionViewIndex = CollectionViewIndex() collectionViewIndex.indexTitles = ["c", "v", "t", "m", "n", "w", "e", "r", "t", "y", "u", "i", "o", "p", "h", "d", "c", "b", "q"] collectionViewIndex.addTarget(self, action: #selector(FakeCollectionViewController.selectedIndexDidChange(_:)), for: .valueChanged) collectionViewIndex.translatesAutoresizingMaskIntoConstraints = false return collectionViewIndex }() 
0
Jul 13 '17 at 9:52 on
source share



All Articles