uitableview滚动事件步进交换

时间:2017-12-22 08:24:43

标签: swift

我有一个tableview和stepper。 步进器被触摸,当tableview被移动时,随机步进器值正在改变。我是否会阻止它。感谢

1 个答案:

答案 0 :(得分:0)

代码

的UIViewController

 import UIKit

 class ViewController:UIViewController,UITableViewDelegate,UITableViewDataSource{


@IBOutlet weak var tablee: UITableView!
override func viewDidLoad() {
    super.viewDidLoad()


}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return 10
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
       let cell = tableView.dequeueReusableCell(withIdentifier: "test", for: indexPath) as! TesttViewCell

      return cell
}
}

TesttViewCell

import UIKit

class TesttViewCell: UITableViewCell {



@IBOutlet weak var adet: UIStepper!
@IBOutlet weak var lblTest: UILabel!

override func awakeFromNib() {
    super.awakeFromNib()
    // Initialization code
}

override func setSelected(_ selected: Bool, animated: Bool) {
    super.setSelected(selected, animated: animated)

    // Configure the view for the selected state
}

@IBAction func changee(_ sender: UIStepper) {
    lblTest.text = String(sender.value)
}
}