我刚开始在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测试期间有没有其他方法可以隐藏键盘?
我按照这个docker-compose教程介绍了如何启动rails应用程序.它运行完美但我更换控制器时不会重新加载应用程序.
有什么可以遗漏的?
我收到以下代码行的警告:
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中的一个错误?
我有以下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中这相当于什么?