我在一个UIPickerView应用程序上有一个iOS。尝试使用calabash在UIPickerView上向下滚动到一个特定的值。这是一份年表。
我试过这样做,看看它是否会滚动:
Then I scroll down on "myPickerAccessibilityLabel"不起作用
UIPickerView有自定义步骤吗?
发布于 2015-06-04 12:54:06
拉塞的回答是正确的(我投了赞成票)。但是要明确的是,它只适用于UIDatePickers。我刚刚查看了Calabash的iOS源代码,看起来我们已经标记了一些私有的选择器方法。下面的是从荆棘宝石抓走的。它使用私有的UIKit选择器来操作选择器车轮。但要注意的是,它可能不适用于非循环(无限)采摘器。
您可以使用下面的代码编写一个步骤,将选择器列滚动到一行文本。
def picker_current_index_for_column (column)
arr = query('pickerTableView', :selectionBarRow)
arr[column]
end
# methods common to generic and date pickers
def picker_current_index_for_column_is(column, val)
picker_current_index_for_column(column) == val
end
def previous_index_for_column (column)
picker_current_index_for_column(column) - 1
end
def picker_next_index_for_column (column)
picker_current_index_for_column(column) + 1
end
def picker_scroll_down_on_column(column)
new_row = previous_index_for_column column
query("pickerTableView index:'#{column}'", [{:selectRow => new_row},
{:animated => 1},
{:notify => 1}])
end
def picker_scroll_up_on_column(column)
new_row = picker_next_index_for_column column
query("pickerTableView index:'#{column}'", [{:selectRow => new_row},
{:animated => 1},
{:notify => 1}])
end
def visible_titles (column)
query("pickerTableView index:#{column} child pickerTableViewWrapperCell", :wrappedView, :text).reverse
end
# May only work on circular pickers - does _not_ work on non-circular
# pickers because the visible titles do _not_ follow the selected index
def selected_title_for_column (column)
selected_idx = picker_current_index_for_column column
titles = visible_titles column
titles[selected_idx]
end
def scroll_picker(dir, column)
if dir.eql? 'down'
picker_scroll_down_on_column column
else
picker_scroll_up_on_column column
end
sleep 0.4
end发布于 2015-06-03 20:55:12
https://stackoverflow.com/questions/30629225
复制相似问题