iphone tableview index
hi guys,
i would like to know if i am able to create a dynamic index in the table view instead of hardcoding it.
i know that there is an example of index in a table in kitchen sink, but it is hardcoded.
is it possible that anyone can help me on it.
thank you!
10 Answers
-
Accepted Answer
ok
Let's try this: http://www.pastie.org/1090469
So I create an empty index array, and an empty temp_index array.
In the for loop I check if the firstLetter exists in the temp_index, and if not I push it into the temp_array, and also create the entry in the index array.The code it's not tested but it should work.
Let me know. -
What do you mean by dynamic ?
You can create the rows in a for loop, depending on what vars you need, push each row to an array, then use this array as argument to setData().
This is what you need?
-
Hey Tamas,
thnx for replying.what i copied from kitchen sink is actually the "table_view_headers_filters". its hardcoded but what i want is to actually go through my xml file and get
e.g. substr(0,1) meaning the first letter of each word out and then throw them into an array so as to display on the right side index. i have also tried the for loop but it doesnt work, keeps on crashing.do u have sample code where i can reference for it?
thanks in advance,
Nicholas -
So actually what's your issue? the xml parsing or the table? or both :)
-
hi Tamas,
xml parsing will be alright, i tink need help in the for loop and the table to create the index. my index meaning its at the right side of the table labeling from (A-Z). so when i click on e.g E it would go to the first word that starts with E.
thanks in advance,
Nicholas
-
Can you post a pastie with what you are doing?
-
hi,
check this
http://www.pastie.org/1090312
thks & regards
-
Hi Varun, thnx i tried it but i cant get it working.
Hi Tamas,
this r my codes and wad i wan it in the image shack:
http://www.pastie.org/1090367
http://img716.imageshack.us/img716/5830/screenshot20100813atpm0.pngin the image, the part where i highlight is what i want but i actually hardcoded it. but i am nt suppose to. do u have any idea for this?
thanks in advance, Nicholas
-
Hi Tamas,
the code works. thanks alot for all the help that u have given! appreciate it alot!
thanks you!
Nicholas
-
Great :) I'm glad I could help.