iOS 8 Expanding Cell Tutorial (Swift)

Christian Di Lorenzo · 34K views · 2015 · 19:27

Open on YouTube

Software (other)Web developmenttutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it as a worked example when asking or answering how to make UITableView cells expand and collapse, and when debugging cell height problems.

Recommended by 3 people across 3 different months, 2015 to 2017.

What it is

A 19-minute Swift tutorial on building expanding table view cells in iOS 8, similar to the date picker row in the native Calendar app. It walks through the code step by step, and an accompanying GitHub repository holds the finished project. It is presented by Christian Di Lorenzo.

What people said

Recommends NoLoHo · 2015-12 · Stack Overflow · on “heightForRowAtIndexPath is called, but the height doesn't change”

Thanks a lot to everybody who tried to help me with this problem!!! I tried everything but I wasn't able to make it work. While Researching I found an approach that works way better for what I wanted than my code posted here. Here's what I'm doing now: [this video] with the help of: Terminating app due to uncaught exception 'NSRangeException', reason: 'Cannot remove an observer - ios [LINK]

Recommends Link Openheim · 2016-07 · Stack Overflow · on “Subviews appearing in unexpected order when height constraint changed”

Hmm... I could not say for sure without some code to look at. I do, however, know a good tutorial that you may skip through just to make sure you have added everything: [this video]

Recommends noblerare · 2017-03 · Stack Overflow · on “Swift 3 - Expandable Table View Cells with first cell already expanded”

I am using Swift 3. I've followed this tutorial to get it so that I can tap on a table view cell which will expand revealing more information. [this video] My question is: how do I do it so that the first cell is expanded when the view loads already (i.e. the user doesn't have to click to see that cell expand) but all other behavior remains the same (e.g. if it's clicked again, it de-collapses)? UITableViewCell : import UIKit class ResultsCell: UITableViewCell { @IBOutlet weak var introPara : UITextView! @IBOutlet weak var section_heading : UILabel! class var expandedHeight : CGFloat { get { return 200.0 } } class var defaultHeight : CGFloat { get { return 44.0 } } var frameAdded = false required

Cites Amsheer · 2015-11 · Stack Overflow · on “Table row height ios Swift”

I am creating an application with a Table view controller. I am following this tutorial link [this video] . Now my problem I want to change the height inside of the items. Each cell has two labels vertically. I set height for the row like this. override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { if (indexPath == selectedIndexPath ){ return 200 }else { return 100 } } How can I change the height of items inside of cell. Edit 1: In default label has only one line of text after clicked there is multiple line of text. So need to change the height of the label and the whole cell. Edit 2: Before click my cell I have like this. [LINK] After I click

Cites Christian Di Lorenzo · 2016-02 · Stack Overflow · on “Terminating app due to uncaught exception 'NSRangeException', reason: 'Cannot remove an observer - ios”

I'm almost completely sure this code is from my YouTube video so I'll go ahead and link to it here ( [this video] ). This fix for the KVO de-register was actually already made to the repository ( [LINK] ).

Cites dpuleri · 2016-02 · Stack Overflow · on “How should I subtract hidden object heights from UIScrollView”

That's not exactly what I would like to do. I don't want to put the UIPickerView inside the popover where the keyboard usually exists. Moreover, if I add the UIPickerView to the UIViewController instead of the UIScollView then it will be outside of the UIStackView that is laying out this whole thing. More similar to what happens at the end of this [this video] . Maybe the only way to do it is with a tableview.

Cites noblerare · 2017-03 · Stack Overflow · on “Swift 3 - Expandable table view cells without closing other ones”

I am using Swift 3. I've been following this tutorial: [this video] , supplemented by this answer [LINK] on StackOverflow. However, the way that this works is that if I click on a cell, it expands while hiding other cells. How do I make it such that when I expand it, the other already-expanded cells stay expanded?