I'm making something that shows the basic label and slider, but I don't know why the code label.text
on Xcode is an error.
error
Swift Compiler Error
Value of type 'UIView' has no member' text'
Did you mean 'next'? (UIKit.UIResponder)
code
import UIKit
classViewController:UIViewController {
@IBOutlet var label:UIView!
@ IBAction func showValue(_sender:UISlider){
label.text="\"(sender.value)"
}
override func viewDidLoad(){
super.viewDidLoad()
// Do any additional setup after loading the view, typically from anib.
}
override funcdidReceiveMemoryWarning(){
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
As you can see in the error message, label
is defined as a variable of type UIView
and the property UIView
does not have the property text
, so the compiler type check fails.
© 2024 OneMinuteCode. All rights reserved.