任何类型的值->;(0)在swift ios10中未启用任何成员
为什么会这样?我不熟悉斯威夫特 我想要record.isEnabled=false,但是我得到这个错误为什么 类型为any->(0)的值未启用任何成员 代码:任何类型的值->;(0)在swift ios10中未启用任何成员,ios,swift,uibutton,Ios,Swift,Uibutton,为什么会这样?我不熟悉斯威夫特 我想要record.isEnabled=false,但是我得到这个错误为什么 类型为any->(0)的值未启用任何成员 代码: 问题是您已连接到@iAction中的录制按钮,而不是@IBOutlet。解决此问题从情节提要中拖动出口用于录制按钮,并将其与适当的文件连接 例如 @IBOutlet weak var record: UIButton! // create the property for your button 完整代码 import UIKit i
问题是您已连接到@iAction中的录制按钮,而不是@IBOutlet。解决此问题从情节提要中拖动出口用于录制按钮,并将其与适当的文件连接 例如
@IBOutlet weak var record: UIButton! // create the property for your button
完整代码
import UIKit
import AVFoundation
class ViewController: UIViewController, AVAudioPlayerDelegate, AVAudioRecorderDelegate {
var audioPlayer: AVAudioPlayer?
var audioRecorder: AVAudioRecorder?
@IBOutlet weak var record: UIButton!
@IBAction func record(_ sender: UIButton!) {
sender.isEnabled = false
}
@IBAction func stop(_ sender: Any) {
record.isEnabled = true
}
@IBAction func play(_ sender: Any) {
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
record.isEnabled = true
}
}
在声明
记录的地方,记录是我的按钮。如果我单击“停止”按钮,我想将“录制”按钮设置为启用。您是否为您的按钮创建了iboutlet?您有与record连接的问题,因为它是@IBAction
而不是@iboutlet。
要解决此问题,请从情节提要中拖动“录制”按钮,并将其与适当的文件连接。是-->>>@IBAction func记录
import UIKit
import AVFoundation
class ViewController: UIViewController, AVAudioPlayerDelegate, AVAudioRecorderDelegate {
var audioPlayer: AVAudioPlayer?
var audioRecorder: AVAudioRecorder?
@IBOutlet weak var record: UIButton!
@IBAction func record(_ sender: UIButton!) {
sender.isEnabled = false
}
@IBAction func stop(_ sender: Any) {
record.isEnabled = true
}
@IBAction func play(_ sender: Any) {
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
record.isEnabled = true
}
}