Greetings Programs!
Here's something odd. I have this tableview which I use for selecting a category but I am getting my first section showing up as a basic cell and the remaining using the custom cell.
Have a look at the pictures; the first picture shows what's happening. The second picture shows what happens if I comment out "objectsModel.enableSearchController = true". The last picture shows what happens if I enableSearchController but remove the sectionHeaderTitleForItem action.
In my IB, I have a tableview with an SCArrayOfObjectsSection with no data definition.
class CategoryListViewController: SCTableViewController { @IBOutlet var sortBy: UISegmentedControl! override func viewDidLoad() { super.viewDidLoad() displayView() } func displayView() { self.navigationBarType = SCNavigationBarType.None; var objectsModel = SCArrayOfObjectsModel(tableView: self.tableView, items: Global.variables.site.categories, itemsDefinition: nil) objectsModel.enableSearchController = true self.tableViewModel = objectsModel self.tableViewModel.modelActions.sectionHeaderTitleForItem = { (itemsModel, item, itemIndex)->String in switch weak_self.sortBy.selectedSegmentIndex { case 1: // Sort by name. return (item.valueForKey("name") as String).leftString(1).uppercaseString default: // By default or selectedSegmentIndex = 0 sort by category. return (item.valueForKey("parentCategoryName") as String).uppercaseString } } self.tableViewModel.sectionActions.didFetchItemsFromStore = { (itemsSection, items) in itemsSection.fetchItemsCell = nil; // This is not the only way to sort, but probably the easiest when using STV var fetchOptions:SCDataFetchOptions switch weak_self.sortBy.selectedSegmentIndex { case 1: fetchOptions = SCDataFetchOptions(sortKey: "name", sortAscending: false, filterPredicate: nil) default: fetchOptions = SCDataFetchOptions(sortKey: "categoryOrder", sortAscending: true, filterPredicate: nil) break; } fetchOptions.sortMutableArray(items) } self.tableViewModel.cellActions.willDisplay = { (cell, indexPath) in if cell.isKindOfClass(SCCustomCell) && cell.boundObject != nil { cell.accessoryType = UITableViewCellAccessoryType.None let category = cell.boundObject.valueForKey("name") as String } } } }
Thoughts?
Wg
Attached Files
Edited by wizgod, 19 January 2015 - 03:07 PM.