小编gim*_*mba的帖子

BLE Swift写字符

我正在努力让我的TI sensortag温度传感器通知.根据http://processors.wiki.ti.com/images/a/a8/BLE_SensorTag_GATT_Server.pdf,我需要将UUID F000AA02-0451-4000-B000-000000000000的特征值设置为"01:00".这是我做的:

import UIKit
import CoreBluetooth

class ViewController: UIViewController, CBCentralManagerDelegate, CBPeripheralDelegate{

    var centralManager:CBCentralManager!
    var blueToothReady = false
    var connectingPeripheral: CBPeripheral!

    @IBOutlet weak var textField: UITextView!

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        startUpCentralManager()
    }

    func startUpCentralManager() {
        centralManager = CBCentralManager(delegate: self, queue: nil)
    }

    func discoverDevices() {
        centralManager.scanForPeripheralsWithServices(nil, options: nil)
    }

    func centralManager(central: CBCentralManager!, didDiscoverPeripheral peripheral: CBPeripheral!, advertisementData: (NSDictionary), RSSI: NSNumber!) {

        output("Discovered", data: peripheral.name)

        self.connectingPeripheral = peripheral
        centralManager.stopScan()
        self.centralManager.connectPeripheral(peripheral, options: nil)

    } …
Run Code Online (Sandbox Code Playgroud)

bluetooth ios core-bluetooth swift

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

java引用不在范围内的对象

当我的 Java 项目变大时,总是会出现一个问题是,是否有一种简单的方法可以引用 super 或 getParent() 无法引用的特定对象。下图应该说明我当前的问题: 在此处输入图片说明

对于每个 FileListItem,我想创建一个新的 FileListItemController,它需要来自 ProtocolController 的方法。除了通过 mainWindow、FileListContentPanel、FileListItems 传递它之外,有没有办法在 FileListItems 中引用由 main 实例化的 ProtocolController 对象?


首先感谢您的所有回答。

我正在为我的项目使用模型、视图、控制模式。

单例模式听起来很有趣,但我的感觉是它不能解决我的问题。这是一些代码来说明我的问题:

public class Main {
    public static void main(String [ ] args) {
        ProtocolController pc = new ProtocolController();
        mainWindow mw = new mainWindow();

    }
}
public class ProtocolController {
    File protocol;
    public ProtocolController(File protocol){
        this.protocol = protocol;
    }

    public void writeSomethingToProtocolFile(String something){
        // write something to th protcol file specified by the object
    }
}
public class mainWindow …
Run Code Online (Sandbox Code Playgroud)

java oop scope object

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

JavaFX Buttontexts 中的颜色单个字母

标题已经描述了我的问题。我想为 JFX 按钮中的单个字母或字母序列而不是整个文本着色。我找到了 Swing 组件的解决方案是否可以在 Java 中将字符串中的文本颜色更改为多种颜色?但还不适用于 javafx。任何人都可以帮助我吗?

button text-coloring letters javafx-2

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

JavaFX getChildren()列表行为

看下面的代码:

public static void main(String[] args) {
        Group group1 = new Group();
        Group group2 = new Group();

        Label label = new Label("test");

        group1.getChildren().add(label);
        group2.getChildren().add(label);

        System.out.println("Size group1: " +group1.getChildren().size());
        System.out.println("Size group2: " +group2.getChildren().size());
    }
Run Code Online (Sandbox Code Playgroud)

如果标签被添加到group2,它将自动从group1中删除.有谁知道为什么这是有意的?

到目前为止,我不需要额外的功能,例如来自组类的边界,并使用简单的ArrayList来存储对标签对象的引用.

javafx list parent

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

此平台不支持CoreBluetooth BLE硬件

要连接到BLE设备,我使用的代码可以在这里找到:

/sf/answers/1807982081/

我在我的macpro上运行代码并激活蓝牙.我可以在设置 - >蓝牙菜单中连接到我的手机但不幸的是,当我运行代码时,我只在控制台上输出"此平台上不支持CoreBluetooth BLE硬件"输出.我还没有开发者帐户,这可能是问题吗?

ios core-bluetooth bluetooth-lowenergy

0
推荐指数
1
解决办法
805
查看次数