Custom Cell Row Height setting in storyboard is not responding

后端 未结 18 2081
名媛妹妹
名媛妹妹 2020-11-30 16:54

I am trying to adjust the cell height for one of the cells on my table view. I am adjusting the size from the \"row height\" setting inside the \"size inspector\" of the cel

18条回答
  •  南方客
    南方客 (楼主)
    2020-11-30 17:14

    Given that I did not find any solution to this problem through Interface Builder, I decided to post a programmatic solution to the problem in Swift using two dynamic cells, even though the initial question asked for a solution through Interface Builder. Regardless I think it could be helpful for the Stack Overflow community:

        import UIKit
    
        enum SignInUpMenuTableViewControllerCellIdentifier: String {
           case BigButtonCell = "BigButtonCell"
           case LabelCell = "LabelCell"
        }
    
        class SignInUpMenuTableViewController: UITableViewController {
                let heightCache = [SignInUpMenuTableViewControllerCellIdentifier.BigButtonCell : CGFloat(50),
                                  SignInUpMenuTableViewControllerCellIdentifier.LabelCell : CGFloat(115)]
    
        private func cellIdentifierForIndexPath(indexPath: NSIndexPath) -> SignInUpMenuTableViewControllerCellIdentifier {
            if indexPath.row == 2 {
                return SignInUpMenuTableViewControllerCellIdentifier.LabelCell
            } else {
                return SignInUpMenuTableViewControllerCellIdentifier.BigButtonCell
            }
        }
    
       override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
           return self.heightCache[self.cellIdentifierForIndexPath(indexPath)]!
       }
    
       ...
    
      }
    

提交回复
热议问题