I have a tableView
where when I call viewForHeaderInSection
before I return the cell. I have this code:
headerCell.layer.zPosition = headerCell.layer.zPosition-1
Now this works in the sense that the cells scroll over the section header which is was I want. But the cell has 3 buttons at the bottom of the frame, when the those buttons scroll over (or should i say under) the sections header content view, the view blocks the buttons and I can no longer tap the buttons even though I can still see them, this is because the cells content view is rendered over the headers view.
If I go in view hierarchy, the header content view is above the cell view which is to blame for blocking the buttons actions.
Does anyone have a work around? or know how to change the headerCell's Zposition to be behind the button? I've tried so many things but I need help.
func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if (cellIdentifier == "vivrCell") {
println(screenSize.width)
if (screenSize.width < 370) {
return 180
}else{
return 220
}
}else {
return 0.0
}
}
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if (cellIdentifier == "vivrCell") {
let headerCell = mainTable.dequeueReusableCellWithIdentifier("vivrHeaderCell") as vivrHeaderCell
headerCell.productID = self.feedReviewResults![section]["product"]["id"].stringValue
headerCell.cellDelegate = self
headerCell.clipsToBounds = false
headerCell.layer.zPosition = headerCell.layer.zPosition-1
return headerCell
}
return nil
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
switch cellIdentifier {
case "vivrCell":
return self.feedReviewResults?.count ?? 0
case "newCell":
return 1
default:
return 1
}
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete method implementation.
// Return the number of rows in the section.
return 1
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
switch cellIdentifier{
case "buzzCell":
var buzzcell = mainTable.dequeueReusableCellWithIdentifier(cellIdentifier) as buzzCell
return buzzcell
case "vivrCell":
var vivrcell = mainTable.dequeueReusableCellWithIdentifier(cellIdentifier) as vivrCell
vivrcell.review = self.feedReviewResults![indexPath.section]
vivrcell.reviewID = self.feedReviewResults![indexPath.section]["id"].stringValue
if let state = self.feedReviewResults![indexPath.section]["current_helpful"].boolValue as Bool?{
vivrcell.helpfullState = state
}
vivrcell.wishlistState = true
vivrcell.cellDelegate = self
vivrcell.layer.zPosition = vivrcell.layer.zPosition
vivrcell.backgroundView = nil
vivrcell.contentView.backgroundColor = UIColor.clearColor()
return vivrcell
default:
let noNewProductsView = UIView(frame: CGRectMake(0, 0, self.view.frame.width, self.view.frame.height))
noNewProductsView.backgroundColor = UIColor.whiteColor()
let checkBackLabel = UILabel(frame: CGRectMake(0, 0, 200, 60.0))
checkBackLabel.numberOfLines = 3
checkBackLabel.textAlignment = NSTextAlignment.Center
checkBackLabel.center = CGPointMake(self.view.center.x, self.view.center.y-100)
checkBackLabel.text = "Check back for new products!"
noNewProductsView.addSubview(checkBackLabel)
var newcell = mainTable.dequeueReusableCellWithIdentifier(cellIdentifier) as newCell
newcell.contentView.addSubview(noNewProductsView)
return newcell
}
}