CoreBluetooth在UITableViewCell中不可用

时间:2016-07-12 09:30:55

标签: ios swift core-bluetooth dynamic-tables

我实现了一个用于向外围设备发送消息的类。 在动态表中打开开关时,应调用此类。

现在的问题是,在UITableViewCell类中不支持CoreBluetooth。 我可以创建一个连接类的对象,但是我无法填写因缺少CoreBluetooth支持而导致的属性。

你知道如何在轻敲开关时实现方法的调用。也许我应该抓住我的应用程序的其他部分。

以下是我的类型为UITableViewCell的类

import UIKit


class remoteCellTableViewCell: UITableViewCell{

    //MARK: Properties
    @IBOutlet weak var remoteCellLabel: UILabel!
    @IBOutlet weak var remoteCellImageView: UIImageView!
    @IBOutlet weak var remoteCellSwitch: UISwitch!
    @IBOutlet weak var remoteCellPower: UIProgressView!

    override func awakeFromNib() {
        super.awakeFromNib()

    }

    //HERE I CAN CATCH THE SWITCH TAP BUT I CAN'T USE CoreBluetooh IN THIS CLASS
    @IBAction func onOff(sender: AnyObject) {


        //OBJECT FROM THE CLASS FOR CONNECT AND SEND TO THE PERIPHERAL
        var connection: ViewController = ViewController()

        connection.viewDidLoad()


        //CANT FILLOUT THE ATTRIBUTES BECAUSE OF MISSING COREBLUETOOTH SUPPORT
    //-->        
        connection.centralManagerDidUpdateState(<#T##central: CBCentralManager##CBCentralManager#>)
        connection.centralManager(<#T##central: CBCentralManager##CBCentralManager#>, didDiscoverPeripheral: <#T##CBPeripheral#>, advertisementData: <#T##[String : AnyObject]#>, RSSI: <#T##NSNumber#>)
        connection.centralManager(<#T##central: CBCentralManager##CBCentralManager#>, didConnectPeripheral: <#T##CBPeripheral#>)
        connection.centralManager(<#T##central: CBCentralManager##CBCentralManager#>, didDiscoverPeripheral: <#T##CBPeripheral#>, advertisementData: <#T##[String : AnyObject]#>, RSSI: <#T##NSNumber#>)
        connection.centralManager(<#T##central: CBCentralManager##CBCentralManager#>, didConnectPeripheral: <#T##CBPeripheral#>)
        connection.peripheral(<#T##peripheral: CBPeripheral##CBPeripheral#>, didDiscoverServices: <#T##NSError?#>)
        connection.peripheral(<#T##peripheral: CBPeripheral##CBPeripheral#>, didDiscoverCharacteristicsForService: <#T##CBService#>, error: <#T##NSError?#>)
        connection.peripheral(<#T##peripheral: CBPeripheral##CBPeripheral#>, didUpdateValueForCharacteristic: <#T##CBCharacteristic#>, error: <#T##NSError?#>)
        connection.peripheral(<#T##peripheral: CBPeripheral##CBPeripheral#>, didWriteValueForDescriptor: <#T##CBDescriptor#>, error: <#T##NSError?#>)

    //->
    }
    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

    }

您会看到方法是通常的CoreBluetooth方法。

有没有办法在这个类中使用这些方法,或者当Switch在动态表中时,我可以在哪里将蓝牙逻辑放在SwitchTap手势后面?

谢谢

0 个答案:

没有答案