小编bbj*_*jay的帖子

如何在UI测试期间在Swift应用程序中隐藏键盘

我刚开始在XCode 7中进行UI测试并遇到了这个问题:

我需要在文本字段中输入文本然后单击按钮.不幸的是,这个按钮隐藏在键盘后面,在将文本输入文本字段时出现.XCode正在尝试滚动以使其可见但我的视图不可滚动因此失败.

我目前的解决方案是:

let textField = app.textFields["placeholder"]
textField.tap()
textField.typeText("my text")
app.childrenMatchingType(.Window).elementBoundByIndex(0).tap() // hide keyboard
app.buttons["hidden button"].tap()
Run Code Online (Sandbox Code Playgroud)

我可以这样做,因为我的ViewController正在拦截触摸:

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
    view.endEditing(false)
    super.touchesBegan(touches, withEvent: event)
}
Run Code Online (Sandbox Code Playgroud)

我对我的解决方案并不满意,在UI测试期间有没有其他方法可以隐藏键盘?

testing user-interface ios swift xcode-ui-testing

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

Docker容器中的Rails应用程序不会在开发中重新加载

我按照这个docker-compose教程介绍了如何启动rails应用程序.它运行完美但我更换控制器时不会重新加载应用程序.

有什么可以遗漏的?

ruby-on-rails docker docker-compose

17
推荐指数
2
解决办法
3178
查看次数

Xcode警告:Format指定类型为'long'但参数的类型为'int _Nullable'

我收到以下代码行的警告:

    NSLog(@"selected segment: %li", _segmentControl.selectedSegmentIndex);
Run Code Online (Sandbox Code Playgroud)

该属性selectedSegmentIndex是类型NSInteger.

如果我将格式更改为%ii,请收到以下警告:

Format specifies type 'int' but the argument has type 'long _Nullable'
Run Code Online (Sandbox Code Playgroud)

Nullable类型是否有任何新的格式说明符,或者这只是Xcode 7中的一个错误?

xcode objective-c xcode7

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

Kotlin相当于Swift字符串枚举(字符串常量的类型化集合)

我有以下Swift枚举:

enum ScreenName: String {
    case start = "Start Screen"
    case dashboard = "My Dashboard Screen"
}
Run Code Online (Sandbox Code Playgroud)

这使我可以拥有一组类型化的常量,并像下面这样使用它们:

func trackView(screen: ScreenName) {
     print("viewed \(screen.rawValue)")
}

trackView(screen: .start) // -> "viewed Start Screen"
Run Code Online (Sandbox Code Playgroud)

在Kotlin中这相当于什么?

enums kotlin swift

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