对于radioButtons,我在按钮中使用了Class,而对于按钮,我使用了标签。 这些是My TextView
h4
这些是我的收音机按钮
@IBOutlet weak var TextViewEveryNewMessage: UILabel!
@IBOutlet weak var TextViewWeekly: UILabel!
@IBOutlet weak var TextViewDaily: UILabel!
@IBOutlet weak var TextViewMonthly: UILabel!
只要按下确定按钮,我就需要在某处保存checkedRadio按钮文字,我就这样做了。
@IBOutlet weak var RadioBtnMonthly: SSRadioButton!
@IBOutlet weak var RadioBtnWeekly: SSRadioButton!
@IBOutlet weak var RadioBtnDefaultChecked: SSRadioButton!
@IBOutlet weak var RadioBtnDaily: SSRadioButton!
这是我正在做的正确方法。还是有其他办法。请建议我。
答案 0 :(得分:1)
不是在preferencesConditions.notificationFrequency
中为OkButton(sender: UIButton)
分配值,而是应该在每个SSRadioButton
按钮中执行此操作,并通过调用 SSRadioButtonControllerDelegate - didSelectButton 强> :
func didSelectButton(aButton: UIButton?) {
print(aButton)
if aButton === RadioBtnDefaultChecked {
preferencesConditions.notificationFrequency = self.TextViewEveryNewMessage.text
}else if aButton === RadioBtnDaily {
preferencesConditions.notificationFrequency = self.TextViewDaily.text
}else if aButton === RadioBtnWeekly {
preferencesConditions.notificationFrequency =
self.TextViewWeekly.text
}else{
preferencesConditions.notificationFrequency = self.TextViewMonthly.text
}
}
不要忘记将委托符合viewController:
var radioButtonController: SSRadioButtonsController?
override func viewDidLoad() {
radioButtonController = SSRadioButtonsController(buttons: RadioBtnDefaultChecked, RadioBtnDaily, RadioBtnWeekly)
radioButtonController!.delegate = self
radioButtonController!.shouldLetDeSelect = true
}
IBAction应该像:
@IBAction func OkButton(sender: UIButton) {
SwiftSpinner.show(kLoadingText)
}
有关详情,请查看SSRadioButtonsController。
希望这会有所帮助。