0

I have a tableview and tabview (3 different tab).I want to show 4 section for first tab , 3 section for second tab and . 2 section for third tab. Just first section's header must be sticky top of the view.Because of this I have implemented headerview just first section but header scrolls and be hidden like a tableview cell .it is not stick on top of the screen.What is the problem here?.Must I implement or override a specific function of tableview?

func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
    if section == 0{
      return UITableView.automaticDimension
    }else {
        return 0 //sadece 1. sectionda tablar header olarak olacak diğerlerinde header olmayacak
    }
}

func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
    return CGFloat.leastNormalMagnitude
}

func numberOfSections(in tableView: UITableView) -> Int {
    if dataReady {
        totalSectionCount = getSectionCount()
        return totalSectionCount
    }else {
        return 1 //permanent because of tabview
    }
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
    if !dataReady || ApplicationContext.instance.userAuthenticationStatus.value == .semiSecure{
        return 1//for shimmer cell and semisecure view
    }else {
        return getNumberOfRows(sectionNumber: section)
    }
}
ahmetvefa53
  • 581
  • 6
  • 20

1 Answers1

0

There is not any function which restricts Specific Header To Stick and Specific To Scroll. If you defined a header for a section, it will scroll up and will be hidden when next section header comes up.

In your case, you must define first header view/cell as Section Header and manage other headers in cellForRowAt() method. Because you want them to scroll up and not stick at top.

Rameez
  • 412
  • 1
  • 5
  • 16
  • Hi Rameez.I manage other headers in cellForRowAt and all other sections does not have a header.Just first section has a header .I did it as you said – ahmetvefa53 Dec 21 '18 at 15:18
  • @ahmetvefa53 Well did you get user interface which you want by using this approach? – Rameez Dec 21 '18 at 16:36