ios - Unexpected Header View in UITableView's section using NSFetchedResultsController -
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?
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
Post a Comment