0
 protocol CustomViewAction: class {
  func customActionButton(_ sender: UIButton)
 }

 class MainFooter: UIView { 
   weak var delegate: CustomViewAction?

   @IBAction func languageButton(_ sender: UIButton) {
     self.delegate?.customActionButton(sender)
   } 
   private func loadNib() {...}
 }


class MainCont: CustomViewAction {
 ...
 let mainFooter = MainFooter()
 mainFooter.frame = view.frame
 mainFooter.delegate = self

 func customActionButton(_ sender: UIButton) {
  ... not working
 }
}

There is custom view. Custom action button interface implemented in the Main controller. This code not working ... Why?

Prasad Devadiga
  • 2,573
  • 20
  • 43
Codegr
  • 3
  • 2
  • You have to load `MainFooter` from nib https://stackoverflow.com/questions/24857986/load-a-uiview-from-nib-in-swift – DionizB Nov 09 '18 at 08:57

1 Answers1

0

It is very bad code) fixe please

protocol CustomViewDelegate: class {
 func actionTouchCustomView(button:UIButton)
}


class MainFooterView: UIView { 
weak var delegate: CustomViewDelegate?

 //MARK: Handle Actions
@IBAction func handleTouchActionLanguageButton(_ sender: UIButton) {
 self.delegate?.actionTouchCustomView(sender)
} 

 //MARK: Life cycle
private func loadNib() {...}
}

class MainCont: CustomViewDelegate {
...
let mainFooter = MainFooter()
mainFooter.frame = view.frame
mainFooter.delegate = self

//MARK -  CustomViewDelegate
func actionTouchCustomView(button:UIButton) {
... not working
}
}
  1. Check link button action in at XIB or Storyboard.
  2. Check life time "let mainFooter". Maybe object is dead