UA-17470720-3

Jump to content


Photo
- - - - -

Cell in SCArrayOfStringsSection not showing selection

cells

  • Please log in to reply
4 replies to this topic

#1 RaduGrama

RaduGrama

    Jr. Member

  • STV 5.0 Pro
  • PipPip
  • 29 posts
  • LocationTampa, FL
Reputation: 6
Good

Posted 08 March 2016 - 06:02 PM

I have a very simple STC VC that contains a single SCArrayOfStringsSection configured with all Allow XXX checkbox in IB unchecked. I am using the SCArrayOfStringsSection as a menu really and I am handling the selection by providing an implementation to self.tableViewModel.cellActions.didSelect. All works great with one exception, when each item is tapped, there is no selection to visually indicate that it is tapped. I tried all options I could think of, but I cannot get the items to show a selection. Any help would be greatly appreciated.



#2 RaduGrama

RaduGrama

    Jr. Member

  • STV 5.0 Pro
  • PipPip
  • 29 posts
  • LocationTampa, FL
Reputation: 6
Good

Posted 08 March 2016 - 06:39 PM

This did the trick for me (code from VC's viewDidLoad):

 

self.tableViewModel.cellActions.didSelect = {
    (cell, indexPath) in
    self.tableView.deselectRowAtIndexPath(indexPath, animated: false)
}

self.tableViewModel.sectionAtIndex(0).cellActions.willConfigure = {
    (cell, indexPath) in
    cell.selectionStyle = UITableViewCellSelectionStyle.Default
}

 

I am not sure if willConfigure is the right place to set cell.selectionStyle, though.


Edited by RaduGrama, 08 March 2016 - 06:40 PM.

  • Tarek likes this

#3 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 08 March 2016 - 07:55 PM

Hi Radu,

 

You can set the cell selection right from IB. Simply select the cell in your SCArrayOfStringsSection and set its style from the object navigator on the right.

 

Hope this helps.



#4 RaduGrama

RaduGrama

    Jr. Member

  • STV 5.0 Pro
  • PipPip
  • 29 posts
  • LocationTampa, FL
Reputation: 6
Good

Posted 09 March 2016 - 09:20 PM

Hi Tarek,

 

That's what I tried initially and it didn't work. The "Selection" attribute in the "Table View Cell" section of the custom cell in the SCArrayOfStringsSection is set to default, but if I check the value in any action, it is  changed to None somewhere and I cannot figure out where. I am assuming it is because I have unchecked "Allow Edit Detail View" for the SCArrayOfStringsController, but I'm not certain. For now the code above does the trick, although it feels a bit like a hack.

 

Thanks,

Radu



#5 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 10 March 2016 - 10:29 AM

Yes, you are correct. Unchecking "Allow Edit Detail View" will prevent the cells from being selected, since developers usually mark that when they simply need some static cells. Since that's not the case for you and all you need is a simple static menu, you could simply use a standard Apple section inside your STV table view and add your static cells there.

 

As for using cellActions.willConfigure, that's also perfectly fine and isn't a hack at all.







Also tagged with one or more of these keywords: cells

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users