gpt4 book ai didi

ios - UITests Xcode7 : How to adjust date picker with multiply pickers?

转载 作者:搜寻专家 更新时间:2023-10-31 22:34:50 25 4
gpt4 key购买 nike

在屏幕上我有 UIDatePicker。如果有简单的选择器就简单了。可能是这样的:

app.pickeWheels["my_id_picker"].adjustToPickerWheelValue("expected_value")

但问题是如何在 UIDatePicker 中调整乘法选择器?

enter image description here

最佳答案

您必须通过指定要调整的选择器的哪个元素/组件来访问不同的轮子。

这是我的代码(在 Swift 2.2 中),带有一个更简单的日期选择器,但我相信您可以调整代码以满足您的需要:

let calendar = NSCalendar.currentCalendar()
let date = NSDate()
let month = calendar.component(NSCalendarUnit.Month, fromDate: date)
let day = calendar.component(NSCalendarUnit.Day, fromDate: date)
let nextMonthName = dateFormatter.monthSymbols[month]

let firstWheel = app.pickerWheels.elementBoundByIndex(0)
firstWheel.adjustToPickerWheelValue("\(nextMonthName)")

let secondWheel = app.pickerWheels.elementBoundByIndex(1)
secondWheel.adjustToPickerWheelValue("\(day+1)")

关于ios - UITests Xcode7 : How to adjust date picker with multiply pickers?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32286770/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com