我正在尝试实现一个简单的步进器,它将其值反映到标签上。 使用" Int(sender.value)"我收到错误"模糊地使用价值"
// ViewController.swift
// Stepper
//
// Created by Prabhu Konchada on 19/06/15.
// Copyright (c) 2015 Prabhu. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var StepperValue: UILabel!
@IBOutlet weak var OutputLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func StepperTap(sender: AnyObject) {
self.OutputLabel.text = String(Int(sender.value).description)
}
}
答案 0 :(得分:3)
你可以这样做:
@IBOutlet var lblStep: UILabel!
@IBAction func stepPressed(sender: UIStepper) {
lblStep.text = sender.value.description
}
否则您必须将AnyObject
转换为UIStepper
像是
var stepControl : UIStepper = sender as! UIStepper
就像:
@IBAction func StepperTap(sender: AnyObject) {
var stepControl : UIStepper = sender as! UIStepper
self.OutputLabel.text = stepControl.value.description
}
整个代码为6.1版,你必须改为as!对于6.3.2:
import UIKit
class ViewController: UIViewController {
@IBOutlet var lblStep: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func stepPressed(sender: AnyObject) {
var step : UIStepper = sender as UIStepper
lblStep.text = step.value.description
}
}
答案 1 :(得分:1)
尝试修改您的代码:
Select * from t1,t2,t3
where t1.id = 1 or t2.id = 1 0r t3.id = 1