I have mainViewController
and inside have scrollView
and I have secondViewController
I want to change scrollView
offset to top from secondViewController
when I want to try it with NSNotificationCenter
gives me ;
: unrecognized selector sent to instance 0x7ff83e024200'
How can I fix it ? My codes under below.
mainViewController
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: "gotop:", name: NSNotification.Name(rawValue: "gotop"), object: nil)
}
func gotop(){
scrollView.setContentOffset(CGPoint(x:0, y:0), animated: false)
}
secondViewController
@IBAction func goButton (sender : UIButton){
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "gotop"), object: nil)
}