I have an indexed UITableView, with an alphabetical list running down the right, similar to the Contacts app.
The issue is, my UITableView has a black background, and when you tap the index view, a rounded gray highlight appears around it -- it's impossible to see the little gray letters (it's gray-on-gray) against the black background.
An easy fix would of course be to change my table background to white, but that's not what my graphic designer wants to do.
Is there any way to change the color of those index letters, or the highlight thing that appears around it? I have read the class docs and just can't seem to find this. It seems like I should be able to somehow set the index's 'style' but I can't figure out where to do that?
Sorry, its too late !! , but i have found the solution for the same.
You have to first set the delegate: _cMIndexBar.delegate = self;
then add the code that you want to do in the delegate method
Code:
- (void)indexSelectionDidChange:(CMIndexBar *)IndexBar:(int)index:(NSString*)title
{
// what ever you want to do with scrolling..i m scrolling at first row of desired section in table view
NSIndexPath *indPath = [NSIndexPath indexPathForRow:0 inSection:i];
[self.table scrollToRowAtIndexPath:indPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
}
I hope this will help you....
Last edited by Abhishek Vashistha; 01-04-2012 at 05:20 AM.
Reason: added code tags
Sorry, its too late !! , but i have found the solution for the same.
You have to first set the delegate: _cMIndexBar.delegate = self;
then add the code that you want to do in the delegate method
- (void)indexSelectionDidChangeCMIndexBar *)IndexBarint)indexNSString*)title
{
// what ever you want to do with scrolling..i m scrolling at first row of desired section in table view
NSIndexPath *indPath = [NSIndexPath indexPathForRow:0 inSection:i];
[self.table scrollToRowAtIndexPath:indPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
Sorry, its too late !! , but i have found the solution for the same.
You have to first set the delegate: _cMIndexBar.delegate = self;
then add the code that you want to do in the delegate method
Code:
- (void)indexSelectionDidChange:(CMIndexBar *)IndexBar:(int)index:(NSString*)title
{
// what ever you want to do with scrolling..i m scrolling at first row of desired section in table view
NSIndexPath *indPath = [NSIndexPath indexPathForRow:0 inSection:i];
[self.table scrollToRowAtIndexPath:indPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
}
First, in your ViewController header file (.h) add the delegate name :
@interface YourViewController : UIViewController <UIViewController <whatever_delegate, ..., CMIndexBarDelegate> {
Then, instead of the suggested "_cMIndexBar.delegate = self" use :
...
[indexBar setIndexes:[NSArray arrayWithArray:...
[self.view addSubview:indexBar];
indexBar.delegate = self;
Finally, within the delegate method :
NSIndexPath *indPath = [NSIndexPath indexPathForRow:0 inSection:7];
[self.yourtableView scrollToRowAtIndexPath:indPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
Cool. That worked, but "NSIndexPath *indPath = [NSIndexPath indexPathForRow:0 inSection:7];" is only going to jump me to section 7.
My index is generated by the entries in my fetched results controller:
So if I hard code "inSection" to "0" then they all jump to section 0. I think every letter is its own section.
Code:
- (void)indexSelectionDidChange:(CMIndexBar *)IndexBar:(int)index:(NSString*)title {
// what ever you want to do with scrolling..i m scrolling at first row of desired section in table view
NSIndexPath *indPath = [NSIndexPath indexPathForRow:0 inSection:0];
[self.myTable scrollToRowAtIndexPath:indPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
}
How would I change that so pressing "A" takes you to "A", "B" takes you to "B", etc?
THen all my enter jump to the same location. How do I tell it
Cool. That worked, but "NSIndexPath *indPath = [NSIndexPath indexPathForRow:0 inSection:7];" is only going to jump me to section 7.
My index is generated by the entries in my fetched results controller:
So if I hard code "inSection" to "0" then they all jump to section 0. I think every letter is its own section.
Code:
- (void)indexSelectionDidChange:(CMIndexBar *)IndexBar:(int)index:(NSString*)title {
// what ever you want to do with scrolling..i m scrolling at first row of desired section in table view
NSIndexPath *indPath = [NSIndexPath indexPathForRow:0 inSection:0];
[self.myTable scrollToRowAtIndexPath:indPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
}
How would I change that so pressing "A" takes you to "A", "B" takes you to "B", etc?
THen all my enter jump to the same location. How do I tell it
Got it your issue ! i will give you complete solution by tomorrow !!!!!