I got problems using this cocoapod .
I want to set the popupHeight for the popup, but it says "Cannot assign to property: 'popupHeight' is a get-only property"...
This is my code:
@IBAction func testBtnPressed(_ sender: Any) {
guard let popupVC = storyboard?.instantiateViewController(withIdentifier: "popup") as? BottomPopupViewController else { return }
popupVC.popupHeight = 50.0 //ERROR!!!
popupVC.popupDelegate = self
present(popupVC, animated: true, completion: nil)
}
Can someone help me? Thanks!
I just checked the link and the sample project. In sample project I can see that they have overridden named as popupHeight
on which you are trying to set a value like this:- override var popupHeight: CGFloat { return height?? CGFloat(300) }
override var popupHeight: CGFloat { return height?? CGFloat(300) }
you can lear more about the get and set
here .
For now what you can do is simply in your BottomPopupViewController
you can simply override this popupHeight
variable and set the value which you want. or else you can do in similar way they have done in the example.
For that:- take a variable named height
or any thing you want like this:- var height: CGFloat?
and then set it while instantiating your View controller like this:- popupVC.height = 50.0
and have the overriden method in your BottomPopupViewController
this one:- override var popupHeight: CGFloat { return height?? CGFloat(300) }
override var popupHeight: CGFloat { return height?? CGFloat(300) }
basically it would take the height you will be setting in here popupVC.height = 50.0
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.