0
I need help in swift for ratingControl, every thing works but the one code that I enterd doesn't seems to work.
//Load button images let bundle = Bundle(for: type(of: self))shows a yellow error: Initialization of immutable value ' let bundle was never used. but if I replace it then it doesn't work.
2 Antworten
0
Are you using the constant bundle in your code somewhere after its initialization? The "yellow error" isn't an error, but just a warning. If you're not using bundle in your code after its initialization, you can try changing its name to _
If you need more help, then you'll need to show more code than just this one line.
0
okay cool. the code from the Initialization is:
override init(frame: CGRect){
super.init(frame: frame)
setupButton()
}
//MARK: Private Methods
private func setupButton() {
//Clear any existing buttons
for button in ratingButtons {
removeArrangedSubview(button)
button.removeFromSuperview()
}
ratingButtons.removeAll()
//Load Button Images
let bundle = Bundle(for: type(of: self))
let filledStar = UIImage(named: "filledStar", in: bundle, compatibleWith: self.traitCollection)
let emptyStar = UIImage(named: "emptyStar", in: bundle, compatibleWith: self.traitCollection)
let highlightedStar = UIImage(named: "highlightedStar", in: bundle, compatibleWith: self.traitCollection)
from ratingButtons it shows the yellow traingle & then 3 red circles that says Expected pattern?