I want to pass the parameter width in the selector rotation function which passes the size.width.
#selector(rotated(width: size.width))
But it's giving me the following error:
Argument of '#selector' does not refer to an '@objc' method, property, or initializer
Any idea how to solve this?
public override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
coordinator.animate(alongsideTransition: { _ in
self.setupConstraints()
self.tableView?.reloadTableData()
}, completion: { _ in })
NotificationCenter.default.addObserver(self, selector: #selector(rotated(width: size.width)), name: UIDevice.orientationDidChangeNotification, object: nil)
}
@objc func rotated(width: CGFloat) {
self.widthAnchorConstraint = tableView?.widthAnchor.constraint(equalToConstant: width)
}