小编kmn*_*kmn的帖子

设计Android EditText以显示谷歌描述的错误消息

我需要一个EditText看起来像这样的onError:

在此输入图像描述

调用onError看起来像这样:

在此输入图像描述

注意:该应用程序在SDK 19(4.4.2)上运行

min SDK是1

有没有类似于setError的方法自动执行此操作,还是我必须为其编写代码?

谢谢

android android-edittext

140
推荐指数
4
解决办法
11万
查看次数

检测Android中的蓝牙Le设备

我是Android应用程序开发的初学者.我已经尝试过阅读文档但是无处可去(Android教程中的功能StartLeScan()已被弃用等等)

是否有一个返回蓝牙设备列表的简单功能?

getDevices()- >(设备列表)?

谢谢

android bluetooth bluetooth-lowenergy

8
推荐指数
1
解决办法
9674
查看次数

使用IOKit与USB设备通信

我正在尝试制作一个与 USB 设备通信的应用程序,其方式与我screen在终端上使用该命令的方式相同。

为了让我的问题更容易理解,这就是我通常在终端中所做的:

命令 :

ls /dev/tty.usb*
Run Code Online (Sandbox Code Playgroud)

返回:

/dev/tty.usbmodem1411   /dev/tty.usbmodem1451
Run Code Online (Sandbox Code Playgroud)

接下来,我打电话:

screen /dev/tty.usbmodem1411
Run Code Online (Sandbox Code Playgroud)

在此之后,我可以向设备发送命令(例如输入“U”,获得响应)

我现在正在尝试从 Xcode 执行此操作。

使用 IOKit,我设法执行了相当于第一个返回 USB 端口列表的命令:

/dev/tty.usbmodem1411   /dev/tty.usbmodem1451
Run Code Online (Sandbox Code Playgroud)

这是代码:

@IBAction func testPressed(sender: AnyObject) {

        var portIterator: io_iterator_t = 0
        let kernResult = findSerialDevices(kIOSerialBSDModemType, serialPortIterator: &portIterator)
        if kernResult == KERN_SUCCESS {
            printSerialPaths(portIterator)
        }

    }

    func findSerialDevices(deviceType: String, inout serialPortIterator: io_iterator_t ) -> kern_return_t {
        var result: kern_return_t = KERN_FAILURE
        var classesToMatch = IOServiceMatching(kIOSerialBSDServiceValue).takeUnretainedValue()
        var classesToMatchDict = (classesToMatch as NSDictionary) as Dictionary<String, AnyObject>
        classesToMatchDict[kIOSerialBSDTypeKey] …
Run Code Online (Sandbox Code Playgroud)

macos cocoa serial-port iokit swift

6
推荐指数
1
解决办法
9425
查看次数

在Ubuntu上使用Swift构建静态链接的可执行文件

我正在尝试从Ubuntu上的快速源构建静态链接的可执行文件。

呼唤

swift build -Xswiftc -static-stdlib

编译带有静态Swift核心库的Swift脚本中所建议

返回此错误:

/usr/bin/ld.gold: error: cannot find -lFoundation

一些有根据的猜测:研究这一点并没有使我走的太远,我知道这意味着找不到该库。也许它不在编译器的路径中?

完整的错误消息:

user@user-VirtualBox:/path/to/project$ swift build -Xswiftc -static-stdlib
Compile Swift Module 'projectName' (4 sources)
Linking ./.build/debug/projectName
/usr/bin/ld.gold: error: cannot find -lFoundation
/usr/bin/ld.gold: error: cannot find -lFoundation
/usr/bin/ld.gold: error: cannot find -lFoundation
/usr/bin/ld.gold: error: cannot find -lFoundation
/path/to/project/Sources/SomeClass_1.swift:67: error: undefined reference to '_TMaC10Foundation17JSONSerialization'
/path/to/project/Sources/SomeClass_1.swift:67: error: undefined reference to '_TFVC10Foundation17JSONSerialization14WritingOptionsau13prettyPrintedS1_'
/path/to/project/Sources/SomeClass_1.swift:68: error: undefined reference to '_TMaC10Foundation8NSString'
/path/to/project/Sources/SomeClass_1.swift:68: error: undefined reference to '_TFVE10FoundationSS8Encodingau4utf8S0_'
/path/to/project/Sources/SomeClass_1.swift:68: error: undefined reference to '_TFC10Foundation8NSStringCfT4dataVS_4Data8encodingSu_GSqS0__' …
Run Code Online (Sandbox Code Playgroud)

ubuntu swift

6
推荐指数
1
解决办法
804
查看次数

如何让CorePlot与swift一起工作?

我阅读了关于如何使用核心情节的教程(http://www.raywenderlich.com/13269/how-to-draw-graphs-with-core-plot-part-1)我正在研究的项目是用迅速.

我做了一切来导入CorePlot库.为了确保我做得对,我创建了一个新的目标C文件并调用

#import "CorePlot-CocoaTouch.h"
Run Code Online (Sandbox Code Playgroud)

它在测试objective-c文件中工作(构建没有错误)

然后我将import语句放在桥接头文件中,并得到27个错误,所有说"...当前部署目标不支持自动__weak"

从这篇文章(Swift中的CorePlot不能称为"numberForPlot"),我知道我可以以某种方式在我的快速项目中使核心情节工作.

谁能推荐一些东西?

谢谢你的帮忙.

我按照以下步骤导入库:

静态库安装您也可以直接将Core Plot库以二进制形式复制到项目中.

  1. 将CorePlotHeaders目录复制到Xcode项目

  2. 将Core Plot库复制到Xcode项目.

  3. 打开您的应用程序目标构建设置,对于其他链接器标志包括:

-ObjC(-all_load曾经被要求作为链接器标志,但在Xcode 4.2中不再需要它)

  1. 将QuartzCore框架添加到项目中.

  2. 将Accelerate框架添加到项目(版本2.0及更高版本).

  3. 将项目构建设置中的C/C++编译器更改为LLVM GCC 4.2或LLVM 1.6.

core-plot ios swift

5
推荐指数
0
解决办法
3421
查看次数

Mac 上的 CoreBluetooth 命令行应用程序

我正在尝试构建一个使用 CoreBluetooth 的命令行应用程序。问题是,它不适用于命令行应用程序。

我已经将我的CoreBluetooth代码(一个实现 CBCentralManagerDelegate 协议的类 - 让我们称之为这个类myBLEManager)从命令行应用程序项目移动到另一个 Mac OS GUI 应用程序。

我在ViewDidLoad()-- supersample 中运行了一些测试,我只是 init amyBLEManager来创建一个CBCentralManageron 初始化实例,然后调用scanForPeripherals.

这就是我在 CLI 和 GUI 项目中所做的。centralManagerDidUpdateState在 CLI 项目中永远不会调用差异。但它在 GUI Mac 应用程序中。

cocoa core-bluetooth swift

4
推荐指数
1
解决办法
955
查看次数

在Ubuntu上进行Swift系统版本检查

我知道Swift有预处理器指令来检查操作系统:

#if os(iOS)
    ...
#elseif os(OSX)
    ...
#endif
Run Code Online (Sandbox Code Playgroud)

但是,在线搜索之后,我发现没有什么可以检查操作系统是Ubuntu.有没有办法做到这一点?我知道swift最近才开始研究Ubuntu,所以我意识到在撰写本文时可能没有办法.

ubuntu swift

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

导航(和状态)栏颜色与编程不同(alpha 自动设置为 0.85)

目标

我正在尝试将我的导航栏着色为灰色(RGB 33、33、33)。问题是,当我使用颜色时,我总是得到更浅的颜色:

UIColor(red: 33/256, green: 33/256, blue: 33/256, alpha: 1)

问题

所以我不得不将颜色变暗到 RGB 8,8,8 才能工作(使用数字色度计验证:获得我想要的 (33,33,33) 灰色)。

编码

我用来执行此操作的代码如下:

    //  NAV BAR
    let navigationBarAppearace =  UINavigationBar.appearance()
    navigationBarAppearace.tintColor = UIColor.white
    navigationBarAppearace.barTintColor = UIColor(red: 0.03, green: 0.03, blue:0.03, alpha: 1)
    navigationBarAppearace.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white]
    
    //  STATUS BAR APPEARANCE
    UIApplication.shared.statusBarStyle = UIStatusBarStyle.lightContent
Run Code Online (Sandbox Code Playgroud)

我发现了什么

我已经使用 Xcode 调试视图层次结构进行了调查,右键单击导航栏并按“打印描述”

在此处输入图片说明

得到这个:

<_UIVisualEffectSubview: 0x15422d1c0; frame = (0 0; 375 64); alpha = 0.85; autoresize = W+H; userInteractionEnabled = NO; layer = <CALayer: 0x1d4224c60>>

这意味着 alpha 已经设置为 0.85(即使我从未明确将其设置为该值),无论是在 …

uikit ios swift

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