UISlider在TableViewCell中没有响应

时间:2018-12-04 05:02:23

标签: ios swift uitableview uislider

我找不到此行为的任何原因。

Here's a screenshot of my environment

我尝试在iPhone测试设备上使用滑块,但是它无法响应我的手势。此外,该曲目丢失。

我还需要提供什么来帮助别人。

这是我的视图控制器的代码:

import UIKit

class SettingTableViewController: UITableViewController {
/*
 @IBOutlet weak var switchInvertColors: UISwitch!
 @IBOutlet weak var switchDisableVibrations: UISwitch!
 @IBOutlet weak var switchAutoSaveOnHome: UISwitch!
 @IBOutlet weak var switchButtonOverlays: UISwitch!
 @IBOutlet weak var switchButtonLock: UISwitch!
 @IBOutlet weak var switchDrawingAlwaysVisible: UISwitch!
 @IBOutlet weak var switchEnableAutoSave: UISwitch!
 @IBOutlet weak var switchIncognitoMode: UISwitch!
 @IBOutlet weak var switchShowTemplate: UISwitch!
 @IBOutlet weak var switchHideConnectionStatusDot: UISwitch!
 */

    @IBOutlet weak var switchInvertColors: UISwitch!
    @IBOutlet weak var switchDisableVibrations: UISwitch!


    @IBOutlet weak var switchAutoSaveOnHome: UISwitch!

    @IBOutlet weak var switchButtonOverlays: UISwitch!
    @IBOutlet weak var switchButtonLock: UISwitch!

    @IBOutlet weak var switchDrawingAlwaysVisible: UISwitch!


    @IBOutlet weak var lineWidth: UISlider!


    @IBOutlet weak var switchEnableAutoSave: UISwitch!
    @IBOutlet weak var switchIncognitoMode: UISwitch!

    @IBOutlet weak var switchShowTemplate: UISwitch!

    @IBOutlet weak var switchHideConnectionStatusDot: UISwitch!


    override func viewDidLoad() {
        super.viewDidLoad()





        // Uncomment the following line to preserve selection between presentations
        // self.clearsSelectionOnViewWillAppear = false

        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem
    }

    // MARK: - Table view data source

    @IBAction func lineWidthChanged(_ sender: UISlider) {
        UserDefaults.standard.set(sender.value, forKey: "lineWidth")

    }
    @IBAction func back(_ sender: UIBarButtonItem) {

        performSegue(withIdentifier: "settingstomain", sender: nil)
    }





    override func viewDidAppear(_ animated: Bool) {


     self.navigationController?.setNavigationBarHidden(false, animated: animated)
        switchInvertColors.isOn = UserDefaults.standard.bool(forKey: "InvertColors")
        switchDisableVibrations.isOn = UserDefaults.standard.bool(forKey: "DisableVibrations")
        switchAutoSaveOnHome.isOn = UserDefaults.standard.bool(forKey: "AutoSaveOnHome")
        switchButtonLock.isOn = UserDefaults.standard.bool(forKey: "ButtonLock")
        switchButtonOverlays.isOn = UserDefaults.standard.bool(forKey: "HideButtonOverlays")
        switchDrawingAlwaysVisible.isOn = UserDefaults.standard.bool(forKey:"DrawingAlwaysVisible")
        switchEnableAutoSave.isOn = UserDefaults.standard.bool(forKey:"AutoSave")
        switchIncognitoMode.isOn = UserDefaults.standard.bool(forKey:"IncognitoMode")
        switchShowTemplate.isOn = UserDefaults.standard.bool(forKey:"ShowTemplate")
        switchHideConnectionStatusDot.isOn = UserDefaults.standard.bool(forKey: "ConnectionStatus")
     //   lineWidth.setValue(UserDefaults.standard.float(forKey:"lineWidth"), animated: true)

    }
    @IBAction func invertColors(_ sender: UISwitch) {
        UserDefaults.standard.set(sender.isOn, forKey: "InvertColors")
    }

    @IBAction func disableVibrations(_ sender: UISwitch) {
        UserDefaults.standard.set(sender.isOn, forKey: "DisableVibrations")
    }

    @IBAction func autoSaveOnHome(_ sender: UISwitch) {
        UserDefaults.standard.set(sender.isOn, forKey: "AutoSaveOnHome")
    }

    @IBAction func buttonLock(_ sender: UISwitch) {
        UserDefaults.standard.set(sender.isOn, forKey: "ButtonLock")
    }


    @IBAction func hideButtonOverlays(_ sender: UISwitch) {
        UserDefaults.standard.set(sender.isOn, forKey: "HideButtonOverlays")
    }


    @IBAction func drawingAlwaysVisile(_ sender: UISwitch) {
        UserDefaults.standard.set(sender.isOn, forKey: "DrawingAlwaysVisible")
    }

    @IBAction func autoSave(_ sender: UISwitch) {
        UserDefaults.standard.set(sender.isOn, forKey: "AutoSave")
    }

    @IBAction func incognitoMode(_ sender: UISwitch) {
        UserDefaults.standard.set(sender.isOn, forKey: "IncognitoMode")
    }

    @IBAction func showTemplate(_ sender: UISwitch) {
        UserDefaults.standard.set(sender.isOn, forKey: "ShowTemplate")
    }


    @IBAction func connectionStatusDot(_ sender: UISwitch) {
        UserDefaults.standard.set(sender.isOn, forKey: "ConnectionStatusDot")
    }

    /*
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath)

        // Configure the cell...

        return cell
    }
    */

    /*
    // Override to support conditional editing of the table view.
    override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
        // Return false if you do not want the specified item to be editable.
        return true
    }
    */

    /*
    // Override to support editing the table view.
    override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
        if editingStyle == .delete {
            // Delete the row from the data source
            tableView.deleteRows(at: [indexPath], with: .fade)
        } else if editingStyle == .insert {
            // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
        }    
    }
    */

    /*
    // Override to support rearranging the table view.
    override func tableView(_ tableView: UITableView, moveRowAt fromIndexPath: IndexPath, to: IndexPath) {

    }
    */

    /*
    // Override to support conditional rearranging of the table view.
    override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool {
        // Return false if you do not want the item to be re-orderable.
        return true
    }
    */

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}

也许我在代码中犯了某种错误,但据我所知没有。

Here is a screenshot of my UISlider in a table cell

我解决了这种情况:它与单元的约束和高度有关。

0 个答案:

没有答案