相关疑难解决方法(0)

didSelectRowAtIndexPath无效,Swift 3

任何人都可以看到为什么世界上没有调用SelectRowAtIndexPath会被调用?我delegate在代码和故事板中都进行了三重检查.

class AddCard: UIViewController,UIPopoverPresentationControllerDelegate, UITableViewDataSource, UITableViewDelegate {

@IBOutlet weak var cardView: UIView!
@IBOutlet weak var tableView: UITableView!

let tableItems = ["Background Color","Background Image","Font Style","Font Color"]
let cellID = "cell"

override func viewDidLoad() {
    super.viewDidLoad()

    tableView.delegate = self
    tableView.dataSource = self
}

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

func setBackgroundColor (_ color: UIColor) {
    cardView.backgroundColor = color
}

func numberOfSectionsInTableView(tableView: UITableView) -> Int {
    return 1
}

func tableView(_ tableView: …
Run Code Online (Sandbox Code Playgroud)

xcode uitableview ios swift

14
推荐指数
1
解决办法
2万
查看次数

如何在ios swift中连接低功耗蓝牙?

我想连接 ble 外设。但我的代码没有调用 didConect 函数

这是我的代码:

func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
 let device = (advertisementData as NSDictionary)
            .object(forKey: CBAdvertisementDataLocalNameKey)
            as? NSString

        if device?.contains(BEAN_NAME) == true {

            print("Did discover peripheral", peripheral)

            self.bluetoothManager.stopScan()
            self._peripheral = peripheral
            self._peripheral.delegate = self
            central.connect(peripheral, options: nil)
        }
}


func centralManager( central: CBCentralManager, didConnect peripheral: CBPeripheral) { //cant call this
        print("connected to \(BEAN_NAME)")
        peripheral.discoverServices(nil)
    }
Run Code Online (Sandbox Code Playgroud)

日志:

BLE service is powered on
Did discover peripheral <CBPeripheral: 0x1740eef00, identifier …
Run Code Online (Sandbox Code Playgroud)

ios bluetooth-lowenergy swift beacon

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

ios ×2

swift ×2

beacon ×1

bluetooth-lowenergy ×1

uitableview ×1

xcode ×1