
How to customize UITableView list?
#1
Posted 03 May 2011 - 07:39 AM
How to:
1) Combine 2 field values and shows list. E.g. I have Name and Gender, and I want to show Name (Gender) in the list, i.e. "Mr. Simpsons (M)", instead of "Mr. Simsons" only.
2) Listing by a different sorting order, e.g. Gender > Name
Thanks
#2
Posted 03 May 2011 - 10:26 AM
In simple cases you could just combine your field properties using ';' i.e.:
sCClassDefinition.titlePropertyName = @"Name;Gender";
sCClassDefinition.titlePropertyNameDelimiter = @" "; //(default)
however because you have bracketed the Gender field and because maybe the prefix could be Mr, Mrs, Miss, Ms etc depending on the gender, maybe you're looking at setting the cell up in the "willDisplayCell" methods of either the tableView delegate or the tableViewCell delegate.
Previous posts in the forum should help you with the sorting - maybe using NSPredicate with NSSortDescriptors.
I'm new here and still trying to get up to speed with STV but I hope this helps for a starter.
Cheers, Carl
#3
Posted 03 May 2011 - 07:35 PM
@Carl: perfectly said, thanks a lot!!

#4
Posted 04 May 2011 - 04:40 AM
#5
Posted 04 May 2011 - 04:42 AM
Hi Guys,
@Carl: perfectly said, thanks a lot!!
How about sorting order? Any way to customize the order or records shown in UITableView list? Thanks
#6
Posted 04 May 2011 - 02:39 PM
As Carl mentioned earlier, you can fully control the sort order (and many other stuff) by providing STV with an NSPredicate. For a simple example on filtering using predicates, please refer to http://www.sensiblec...cope.html#2566. For more on NSPredicate, please refer to Apple's documentation.
#7
Posted 04 September 2011 - 09:04 AM
Question: is it possible to reverse the order without resorting to an NSPredicate method?
Thanks!!
#8
Posted 05 September 2011 - 05:45 PM
If all you need is just reverse the sorting order of your objects on the given key, just set your SCArrayOfObjectsSection 'sortItemsSetAscending' property to FALSE.
Hope this helps.
#9
Posted 05 September 2011 - 06:30 PM
I have this code:
SCArrayOfObjectsSection *objectsSection = [SCArrayOfObjectsSection sectionWithHeaderTitle:nil withEntityClassDefinition:taskDef]; objectsSection.addButtonItem = self.navigationItem.rightBarButtonItem; objectsSection.sortItemsSetAscending = FALSE;
I get this error:
*** Assertion failure in -[_UITableViewUpdateSupport _computeRowUpdates], /SourceCache/UIKit_Sim/UIKit-1906/UITableViewSupport.m:386
2011-09-06 00:00:05.741 taskApp[22906:fb03] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unable to resolve row for index path:2 indexes [0, 0]'
#10
Posted 05 September 2011 - 06:40 PM
I am not sure this has anything to do with sortItemsSetAscending. Is this the same project you're sending me?
#11
Posted 05 September 2011 - 06:48 PM
I only get the error with that code. Take it out and it works ok..
David
Ps. Thank you for all the help. I look forward to helping others.
#12
Posted 07 September 2011 - 01:29 PM

I did have a look at your app and this seems to be a glitch in STV. We'll fix this ASAP, thank you very much for reporting it.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users