Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 04-08-2009, 03:40 PM   #1 (permalink)
Registered Member
 
Join Date: Sep 2008
Location: Portland, Oregon
Posts: 46
higgins is on a distinguished road
Default Change color of index letters in UITableView?

Hi all,

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?
higgins is offline   Reply With Quote
Old 04-08-2009, 04:15 PM   #2 (permalink)
New Member
 
Join Date: Sep 2008
Posts: 1,431
PhoneyDeveloper is on a distinguished road
Default

I don't think there's any way to customize the appearance of the index.
PhoneyDeveloper is offline   Reply With Quote
Old 04-10-2011, 06:03 AM   #3 (permalink)
Registered Member
 
Join Date: Jul 2008
Posts: 36
Craig2 is on a distinguished road
Default

For anyone else searching I created a small and simple bit of code for doing this https://github.com/Hyabusa/CMIndexBar
Craig2 is offline   Reply With Quote
Old 04-10-2011, 06:07 AM   #4 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

or look here

iphone - How do I change the color of the side Alphabet in an indexed UITableView? - Stack Overflow
__________________
dany_dev is offline   Reply With Quote
Old 07-04-2011, 11:59 PM   #5 (permalink)
Registered Member
 
krye's Avatar
 
Join Date: Jan 2009
Location: NY, USA
Posts: 359
krye is on a distinguished road
Default

Quote:
Originally Posted by Craig2 View Post
For anyone else searching I created a small and simple bit of code for doing this https://github.com/Hyabusa/CMIndexBar
Looks cool. I got my index to appear, but the table doesn't jump to the index selected.

I see you added this as a delegate. But what goes under it? What am I missing?

Code:
- (void)indexSelectionDidChange:(CMIndexBar *)IndexBar:(int)index:(NSString*)title;
Thanks
krye is offline   Reply With Quote
Old 01-04-2012, 02:03 AM   #6 (permalink)
Registered Member
 
Join Date: Jan 2012
Location: Jaipur, India
Posts: 2
Abhishek Vashistha is on a distinguished road
Default

Quote:
Originally Posted by krye View Post
Looks cool. I got my index to appear, but the table doesn't jump to the index selected.

I see you added this as a delegate. But what goes under it? What am I missing?

Code:
- (void)indexSelectionDidChange:(CMIndexBar *)IndexBar:(int)index:(NSString*)title;
Thanks
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
Abhishek Vashistha is offline   Reply With Quote
Old 01-04-2012, 05:01 AM   #7 (permalink)
Registered Member
 
krye's Avatar
 
Join Date: Jan 2009
Location: NY, USA
Posts: 359
krye is on a distinguished road
Default

Quote:
Originally Posted by Abhishek Vashistha View Post
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];

}

I hope this will help you....
Thanks. I'll try it tonight and report back.
krye is offline   Reply With Quote
Old 02-07-2012, 05:38 PM   #8 (permalink)
Registered Member
 
krye's Avatar
 
Join Date: Jan 2009
Location: NY, USA
Posts: 359
krye is on a distinguished road
Default

Quote:
Originally Posted by Abhishek Vashistha View Post
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....
Still confused. Where did you put:

Code:
_cMIndexBar.delegate = self;
Thanks
krye is offline   Reply With Quote
Old 02-12-2012, 02:09 PM   #9 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 16
pinky is on a distinguished road
Default

Quote:
Originally Posted by krye View Post
Still confused. Where did you put:

Code:
_cMIndexBar.delegate = self;
Thanks
Hello Krye,
voyages vietnam
Running Skirts
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];

Now, when sliding your finger onton the indexBar, the tableview should scroll 'till the 8th section (if you have one)...

You might smile by now...

After, you can stick to his other suggestion

Enjoy! ;-)

- A easy goin' french programmer from Paris -

Last edited by pinky; 05-10-2012 at 02:46 PM.
pinky is offline   Reply With Quote
Old 02-13-2012, 07:58 PM   #10 (permalink)
Registered Member
 
krye's Avatar
 
Join Date: Jan 2009
Location: NY, USA
Posts: 359
krye is on a distinguished road
Default

Quote:
Originally Posted by pinky View Post
Hello Krye,

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:

Code:
//letters for index
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
	   
    //custom indexbar
    CMIndexBar *customIndex = [[CMIndexBar alloc] initWithFrame:CGRectMake(self.view.frame.size.width-35, 10.0, 28.0, self.view.frame.size.height-20)];
    [customIndex setIndexes:[fetchedResultsController sectionIndexTitles]];
    [self.view addSubview:customIndex];
    [customIndex release];

customIndex.delegate = self;
    	
    return nil;
    
}
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
krye is offline   Reply With Quote
Old 02-15-2012, 05:55 AM   #11 (permalink)
Registered Member
 
Join Date: Jan 2012
Location: Jaipur, India
Posts: 2
Abhishek Vashistha is on a distinguished road
Default

Quote:
Originally Posted by krye View Post
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:

Code:
//letters for index
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
	   
    //custom indexbar
    CMIndexBar *customIndex = [[CMIndexBar alloc] initWithFrame:CGRectMake(self.view.frame.size.width-35, 10.0, 28.0, self.view.frame.size.height-20)];
    [customIndex setIndexes:[fetchedResultsController sectionIndexTitles]];
    [self.view addSubview:customIndex];
    [customIndex release];

customIndex.delegate = self;
    	
    return nil;
    
}
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 !!!!!
Abhishek Vashistha is offline   Reply With Quote
Old 02-19-2012, 08:19 PM   #12 (permalink)
Registered Member
 
krye's Avatar
 
Join Date: Jan 2009
Location: NY, USA
Posts: 359
krye is on a distinguished road
Default

Quote:
Originally Posted by Abhishek Vashistha View Post
Got it your issue ! i will give you complete solution by tomorrow !!!!!
Any luck? Thanks.
krye is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 330
7 members and 323 guests
blueorb, guusleijsten, jbro, Kryckter, LEARN2MAKE, n00b, SLIC
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,880
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:57 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0