ios - Unexpected Header View in UITableView's section using NSFetchedResultsController -


enter image description here

it easy see, lightblue uitableviewheaderfooterview, , white 1 uitableviewcell. use nsfetchedresultscontroller load sections , groups coredata. every blue header new section.

sometimes (not always) there header view instead of table view cell. why?

in viewdidload register header view:

tableview.registernib(uinib(nibname: "pbouserworkdayheaderview", bundle: nil), forheaderfooterviewreuseidentifier: pbouserworkdayheaderviewidentifier) 

what more interesting, when debug view hierarchy can see, there custom cell, covered header. why?

enter image description here

is ios bug? think? sth wrong rendering or way of thinking?

since problem headers, created custom method remove unnecessary headers every time when tableview ask `viewforheaderinsection:.

assuming know how distinguish headers other views (in case have custom class) , know header views direct subviews of tableview can remove them in following way:

private func removedoubledheaders() {     let subviews = tableview.subviews.reverse()      var dates = [string]()     view in subviews {         if let header = view as? pbouserworkdayheaderview {             if let date = header.datelabel.text {                 if contains(dates, date) {                     view.removefromsuperview()                 } else {                     dates.append(date)                 }             }         }     } } 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -