我已经在我的应用程序(日历)上对按钮进行了编码以突出显示。但是,当我转到不同的 View Controller 时,它不会保存我突出显示的内容。当我选择返回到上一个 View Controller 时,是否需要编写 DestViewController 或其他内容来保存突出显示的按钮?我正在使用 Swift 语言,并且处于单应用程序 View 应用程序中。 Main View Controller, when the user presses PICK DAYS it goes to the January January View Controller
最佳答案
您可以保存先前突出显示的按钮的数组,并在 viewWillAppear
中将突出显示的值设置为 true
示例
class CalenderViewController: UIViewController{
var highlightedBtns = [UIButton]()
override func viewWillAppear(animated: Bool) {
highlightBtns()
}
func highlightBtns(){
if highlightedBtns.count > 0{
for btn in highlightedBtns{
btn.highlighted = true
}
}
}
@IBAction func calenderBtn(sender: UIButton){
highlightedBtns.append(sender)
//other actions
}
}
关于ios - 在不同的 View Controller 上保存突出显示的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36213836/