Side Menu looses custom visuals when touched

Thread is closed for posting
3 posts, 0 answers
  1. Sal
    Sal avatar
    58 posts
    Member since:
    Feb 2015

    Posted 11 Dec 2015 Link to this post

    In my side menu I'm using custom cells for the menu using the cellForItemAtIndexPath delegate method but when a user clicks on one of the cells that isn't interactive (I have two cells that are there purely for informational purposes so I set the selection style to None on both of them) the table view reloads and looses all of the custom styling from the cellForItemAtIndexPath and just shows each item in plain black text. 


    Here's some code that I have, not sure what you would need so just pasting chunks of it


    func sideDrawer(sideDrawer: TKSideDrawer!, cellForItemAtIndexPath indexPath: NSIndexPath!) -> TKSideDrawerTableViewCell! {
            let cell = TKSideDrawerTableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "cell")
            let section = sideDrawer.sections[indexPath.section] as! TKSideDrawerSection
            let item = section.items[indexPath.item] as! TKSideDrawerItem
            //the first section contains the rep name and location centered in the table
            if indexPath.section == 0 {
                if indexPath.row == 0 {
                    let centeredCell = CenterLabelCell()
                    centeredCell.selectionStyle = UITableViewCellSelectionStyle.None
                    centeredCell.item = item
                    return centeredCell
                else if indexPath.row == 1 {
                    let centeredImageAndTextCell = CenterLabelWithImageCell()
                    centeredImageAndTextCell.selectionStyle = UITableViewCellSelectionStyle.None
                    centeredImageAndTextCell.item = item
                    return centeredImageAndTextCell
            //the second section only needs a special cell if the row is selected
            if indexPath.section == 1 || indexPath.section == 2 {
                //get the currently selected index
                let selectedDict = NSUserDefaults.standardUserDefaults().objectForKey(KeyValues.keySelectedIndex()) as! NSDictionary
                let currentIndex = NSIndexPath().convertDictToIndexPath(selectedDict)
                //set selected index to have tint on both image and text
                if indexPath == currentIndex {
                    let selectedCell = SelectedTableCell()
                    selectedCell.item = item
                    return selectedCell
                else {
                    let regularCell = NonSelectedTableCell()
                    regularCell.item = item
                    return regularCell
            return cell


    and here's the code from the didSelectItemAtIndexPath method

    func sideDrawer(sideDrawer: TKSideDrawer!, didSelectItemAtIndexPath indexPath: NSIndexPath!) {
            //let section = sideDrawer.sections()[indexPath.section] as! TKSideDrawerSection
            //let item = section.items()[indexPath.item] as! TKSideDrawerItem
            let section = indexPath.section
            if section == 1 || section == 2 {
                //first check if the person selected the same index that is currently being viewed
                let indexDict = NSUserDefaults.standardUserDefaults().objectForKey(KeyValues.keySelectedIndex()) as! NSDictionary
                let previousIndex : NSIndexPath = NSIndexPath().convertDictToIndexPath(indexDict)
                if previousIndex != indexPath {
                    //store selected index
                    NSUserDefaults.standardUserDefaults().setObject(indexPath.convertIndexPathToDict(), forKey: KeyValues.keySelectedIndex())
                    //give the menu enough time to close before replacing the view with the new view
                    //self.performSelector("showNewViewController:", withObject: indexPath, afterDelay: 0.2)
                    let delay = 0.25
                    let intDelay = Int64(delay * Double(NSEC_PER_SEC))
                    let popTime = dispatch_time_t(dispatch_time(DISPATCH_TIME_NOW, intDelay))
                    dispatch_after(popTime, dispatch_get_main_queue(), { Void in
                    //after any selection call the setup method again just to make sure the custom views stay the same



  2. Sal
    Sal avatar
    58 posts
    Member since:
    Feb 2015

    Posted 11 Dec 2015 Link to this post

    I believe I found a solution that works. Due to how I was using my side menu it was getting re-drawn after every selection so on the sections that I don't have any interactions with I just called the removeAllSections method and then when it's redrawn it shows up correctly. Thanks. 
  3. Adrian
    Adrian avatar
    174 posts

    Posted 15 Dec 2015 Link to this post

    Hello, Sal,

    Thank you for writing.

    I am glad to understand that you found a solution for the issue. However we could not reproduce it, could you please send me a sample project that can be compiled and where the issue occurs so I could investigate it further?

    Thank you for your cooperation. I am looking forward to your reply. 

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top