Swift: How to use static cell in dynamic UITableView

Mehmet
static
dynamic
dynamic
dynamic
..
..
dynamic

I've a dynamic table list with dynamic content. At the top of list, I need a static cell.

And trying to add a Label in my static cell to try features.

My static cell's identifier is: firstCell

Dynamic cell's identifier is: cell

override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
    // #warning Potentially incomplete method implementation.
    // Return the number of sections.
    return 1
}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    // #warning Incomplete method implementation.
    // Return the number of rows in the section.
    return 5
}


override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! UITableViewCell

    // Configure the cell...

    cell.textLabel?.text = "test"


    return cell
}

This code return 5 times "test" in my dynamic cells. When I am try to add a Label and create outlet with static cell, get error.

I've googled and searched on stackoverflow but there is no swift version solution. How can do that?

EDIT FOR IMPROVE TO QUESTION:

Actually I need two section and section1 will be static content (I will create it programatically. E.g will use uidatepicker, uipicker and more..), section2 will work with just an dynamic array (this part is okey)

Kutyel

Have you tried something like this?

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! UITableViewCell

    if (indexPath.row == 1) {
        cell.textLabel?.text = "test"
    } else {
        // Configure the cell...
    }

    return cell
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Swift: How to use static cell in dynamic UITableView

From Dev

Static UITableView, make a single cell with dynamic height in Swift

From Dev

Dynamic UITableView inside static cell

From Dev

Dynamic UITableView inside static cell

From Dev

Swift: How to get the value of a slider in a custom cell in a dynamic UITableView?

From Dev

Swift: UICollectionView with dynamic and static cell

From Dev

Swift: UICollectionView with dynamic and static cell

From Dev

How to create static cells with dynamic cell heights with Swift

From Dev

How to add a Cell into a static section UITableView?

From Dev

How to add a Cell into a static section UITableView?

From Dev

Swift: How to use "estimatedRowHeight" ?Dynamic Cell Height Stange errors

From Dev

How to create a Prototype cell in a Dynamic UITableView?

From Dev

How to change cell height dynamically in UITableView static cell

From Dev

UITableView inside static cell

From Dev

Static cell at the bottom of a UITableView

From Dev

Dynamic UITableView Cell Heights Programmatically IOS7 in Swift

From Dev

Uitableview cell dynamic height

From Dev

Dynamic cell size uitableview

From Dev

How to detect Cell selection in UITableView - Swift

From Java

How to insert new cell into UITableView in Swift

From Dev

How to select UITableView cell programmatically (Swift 2)

From Dev

How to hide specific cells in a static UItableview, in swift?

From Dev

How to hide specific cells in a static UItableview, in swift?

From Dev

UITableView cell creation on Swift

From Dev

How to add an icon to an iOS static uitableview cell in the storyboard

From Dev

How to drag a static cell into tableView swift?

From Dev

No Enough Cell to Use in UITableView

From Dev

UItableView with static cells contains 2 UItableviews each with custom cell with dynamic height

From Dev

UITableView Mix of Static and Dynamic Cells?

Related Related

  1. 1

    Swift: How to use static cell in dynamic UITableView

  2. 2

    Static UITableView, make a single cell with dynamic height in Swift

  3. 3

    Dynamic UITableView inside static cell

  4. 4

    Dynamic UITableView inside static cell

  5. 5

    Swift: How to get the value of a slider in a custom cell in a dynamic UITableView?

  6. 6

    Swift: UICollectionView with dynamic and static cell

  7. 7

    Swift: UICollectionView with dynamic and static cell

  8. 8

    How to create static cells with dynamic cell heights with Swift

  9. 9

    How to add a Cell into a static section UITableView?

  10. 10

    How to add a Cell into a static section UITableView?

  11. 11

    Swift: How to use "estimatedRowHeight" ?Dynamic Cell Height Stange errors

  12. 12

    How to create a Prototype cell in a Dynamic UITableView?

  13. 13

    How to change cell height dynamically in UITableView static cell

  14. 14

    UITableView inside static cell

  15. 15

    Static cell at the bottom of a UITableView

  16. 16

    Dynamic UITableView Cell Heights Programmatically IOS7 in Swift

  17. 17

    Uitableview cell dynamic height

  18. 18

    Dynamic cell size uitableview

  19. 19

    How to detect Cell selection in UITableView - Swift

  20. 20

    How to insert new cell into UITableView in Swift

  21. 21

    How to select UITableView cell programmatically (Swift 2)

  22. 22

    How to hide specific cells in a static UItableview, in swift?

  23. 23

    How to hide specific cells in a static UItableview, in swift?

  24. 24

    UITableView cell creation on Swift

  25. 25

    How to add an icon to an iOS static uitableview cell in the storyboard

  26. 26

    How to drag a static cell into tableView swift?

  27. 27

    No Enough Cell to Use in UITableView

  28. 28

    UItableView with static cells contains 2 UItableviews each with custom cell with dynamic height

  29. 29

    UITableView Mix of Static and Dynamic Cells?

HotTag

Archive