Reputation: 261
I have taken a Xib
of UIView
named "CustomerView" inside which i have dragged a tableView
and also created a separate Xib
file for tableView
, How can show "CustomerView" view of xib.on View contoller and tableview with data in Swift 3.I know how to show customer cell with xib on view controller with tableview data.Can anyone help me i will be very thankful
Upvotes: 3
Views: 335
Reputation: 1197
here anyview is a uiview which u want to show or hide
extension ViewController : UITableViewDelegate {
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
return any view
}
func instanceFromNib() -> UIView {
return UINib(nibName: "Header", bundle: nil).instantiate(withOwner: nil, options: nil)[0] as! UIView
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 200;
}
have a button action like below
@IBAction func HideShowView(_ sender: UIButton) {
if(!isSelected) {
isSelected = true
self.mytable.delegate = nil
mytable.reloadData()
}
else {
isSelected = false
self.mytable.estimatedRowHeight = 40
self.mytable.delegate = self
mytable.reloadData()
}
}
Upvotes: 1