我已经做了大量的搜索但是没有找到我的问题的答案。
我的两个UILabel
字段正在使用clear函数重置。 import UIKit
class ViewController: UIViewController {
@IBOutlet weak var inputFeet: UITextField!
@IBOutlet weak var inputWatts: UITextField!
@IBOutlet weak var resultsLabel: UILabel!
var stripFeet = ""
var wattValue = ""
var totalWatts : Float = 0.0
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
@IBAction func submitButton(sender: AnyObject) {
calculateWatts()
}
@IBAction func clearButton(sender: AnyObject) {
clear()
}
func calculateWatts() {
if let stripFeet = inputFeet.text,
wattValue = inputWatts.text,
fstripFeet = Float(stripFeet),
fwattValue = Float(wattValue){
totalWatts = fstripFeet * fwattValue
}
printWatts()
}
func printWatts() {
let formatWatts = String(format: "%0.2f", totalWatts)
resultsLabel.text = "Total watts: \(formatWatts)"
}
func clear(){
inputFeet.text = ""
inputWatts.text = ""
self.resultsLabel.text = ""
}
}
保留printWatts函数的原始值,不清楚。当我学习Swift时,我将不胜感激任何解决这个小问题的建议。谢谢!
var jsExecutor = /*Get your WebDriverInstance*/ as IJavaScriptExecutor;
while(/*your required timeout here*/)
{
var ajaxComplete =
jsExecutor.ExecuteScript("return ((typeof Ajax === 'undefined') ||
Ajax.activeRequestCount == 0) && ((typeof jQuery === 'undefined') || $.active == 0)");
if (ajaxIsComplete)
return
}
答案 0 :(得分:0)
感谢@Eendje建议我查看我的连接。我将提交和清除操作都连接到我的提交按钮。选项拖动太方便了。一切都好。