我制作了一个应用程序Single Application。我放了一个名为Dim LC1 As Long, ColNum1 As Long
Application.ScreenUpdating = False
For ColNum1 = 8 To Cells(1, Columns.Count).End(xlToLeft).Column
For LC1 = 2 To Cells(Rows.Count, ColNum1).End(xlUp).Row
If Val(CStr(Cells(LC1, ColNum1))) < 0 Then Cells(LC1, ColNum1) = 0
Next LC1
Next ColNum1
Application.ScreenUpdating = True
的按钮,一个名为CountUpButton
的标签和另一个按钮CountLabel
。 ResetButton
的功能是按下按钮时,CountUpButton
必须更改CountLabel
,按下+ 1
时,ResetButton
必须转为{{1} }}。但问题是每当我重启我的iPhone或App时,CountLabel
都会变回0.它应该保存0
,因此只有在按下CountLabel
时才需要更改。 / p>
此功能的代码是:
CountLabel
我用于保存“CountLabel”的代码是:
ResetButton
答案 0 :(得分:1)
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var counterLabel: UILabel!
var counter: Int {
return NSUserDefaults().integerForKey("counter")
}
override func viewDidLoad() {
super.viewDidLoad()
counterLabel.text = "\(counter)"
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
@IBAction func countUp(sender: AnyObject) {
NSUserDefaults().setInteger(counter+1, forKey: "counter")
counterLabel.text = "\(counter)"
}
@IBAction func resetCounter(sender: AnyObject) {
NSUserDefaults().removeObjectForKey("counter")
counterLabel.text = "\(counter)"
}
}