(I tested this with iOS 9, 10, and 11)

In newer versions of iOS (maybe 9?), you can do away with custom height calculation of collection view cells, and rely entirely on flow layout’s estimatedItemSize function and autolayout to automatically find the correct height and width. However, sometimes a custom, manual, height calculation is required. Examples would be when you want to fit the width of a cell the entire width of the screen, or when you want to force a height to be 0, then you’ll need manual calculation.


As a reference for myself and others, I documented this down so no one will need to fiddle with this again in the future. So assuming you have a collection view in place, and a custom cell subclass, let’s put in the pieces to make the above image work.

Reference Code

Within the ViewController class:

// 1.
class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout
  1. Whichever class you have that’s going to be doing the height calculation needs to conform to UICollectionViewDelegateFlowLayout
// 2.
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellIdentifier, for: indexPath) as! TestCell
        configure(cell: cell)
        return cell
    // 3.
    func configure(cell: TestCell) {
        cell.titleLabel.text = "Ooh woo, I'm a rebel just for kicks, now. I been feeling it since 1966, now. Might've had your fill, but you feel it still"
        cell.subtitleLabel.text = "Feel It Still, by Portugal. The Man. Pretty good song I'm listening to while writing the configure method of this cell. "
    // 4.
    let sizingCell = TestCell()
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
        // 5.
Read the rest

1. Delete the storyboard (your first step to the light side, storyboards are truly awful).



2. In Info.plist, delete the line Main Storyboard file base name


3. In the AppDelegate, modify the didFinishLaunchingWithOptions function to make your view controller the root view controller of the window, and then make the window visible.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    let vc = ViewController()

    window = window = UIWindow(frame: UIScreen.main.bounds)
    window?.rootViewController = vc
    return true
Read the rest

Working in engineering at various sized companies has taught me that hiring is one of the clearest ways a company’s true colors come out. How a company approaches referrals, hiring decisions, conflicts of interest, and transparency has a direct impact on employee morale. It is especially powerful, because it’s something that employees are directly involved and invested in, and affected by. However, it can swing in either direction, either increasing employee loyalty and feelings of ownership, or leave people feeling disengaged and powerless.

In the good scenarios I’ve been in, referrers did not have a say in hiring decisions. Though they gave feedback about this person they had worked with before, the hiring decision was not up to them. The decision was left to the people who would be working with the person day to day. My feeling after the process was that I was treated fairly and I had a say in what happened here. It gave me a feeling of responsibility. One, I have a say in who I’d be working with, and two, who has an impact on the company that I had invested myself in.

On the opposite end of the spectrum, poor situations have included opaque hiring decisions that were the basis of a single powerful person’s say, sometimes against the recommendation of all others who interviewed. It’s like saying, “Your vote doesn’t count”. It’s a little cut, but one in an important place. Why would I continue to invest in a place that discounts my opinion. On top of that, what a waste of everybody’s time if it didn’t matter anyway.… Read the rest