[ad_1]
I’ve a backside sheet, and on that sheet there’s a button. I would like that when i faucet to that button it go to the web page it’s associated to. So, i related that from storyboard to code
@IBOutlet weak var openPage: SheetOpenPageButton!
And wrote extension for the button.
class SheetOpenPageButton: UIButton {
var navigationController: UINavigationController?
override var isSelected: Bool {
didSet {
if isSelected {
self.backgroundColor = UIColor(named: "CustomRed")
} else {
self.backgroundColor = UIColor(named: "CustomGray")
}
}
}
required init(coder aDecoder: NSCoder) {
tremendous.init(coder: aDecoder)!
}
required override init(body: CGRect) {
tremendous.init(body: body)
}
}
Within the collectionview, the place i’m clicking on button, i name these strategies.
let button = SheetOpenPageButton()
button.tag = cell.id ?? 1
button.addTarget(self, motion: #selector(goToRestuarantFromStory(_ :)), for: .touchUpInside)
@objc func goToRestuarantFromStory(_ sender : UIButton) {
let restuarantVC = UIStoryboard(title: "Cafe", bundle: .most important).instantiateViewController(withIdentifier: "RestuarantViewController") as! RestuarantViewController
restuarantVC.networkId = sender.tag
navigationController?.pushViewController(restuarantVC, animated: true)
print("smth")
removeSubview()
removeSubviewSpb()
vc.dismiss(animated: true, completion: nil)
}
Right here i’m passing parameter in addtarget utilizing button’s tag.
However, when tapping on button it does not give a response. I do not know tips on how to resolve this.
[ad_2]
