How to customize UITableView list?
Posted 03 May 2011 - 07:39 AM
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
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.
Posted 04 May 2011 - 04:40 AM
Posted 04 May 2011 - 04:42 AM
@Carl: perfectly said, thanks a lot!!
How about sorting order? Any way to customize the order or records shown in UITableView list? Thanks
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.
Posted 04 September 2011 - 09:04 AM
Question: is it possible to reverse the order without resorting to an NSPredicate method?
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.
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]'
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?
Posted 05 September 2011 - 06:48 PM
I only get the error with that code. Take it out and it works ok..
Ps. Thank you for all the help. I look forward to helping others.
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