2014-04-01 28 views
1

所以,我有以下的日期選取器查看:弗蘭克測試:UIPickerView不會在細胞更新值

enter image description here

這是連接到Date of Birth細胞:

enter image description here

現在,在我的弗蘭克測試中,我想移動翻轉杯,然後在文本框中反映最終值。我做了以下操作:

dateValue = "04.11.2002" 
dateParts = dateVale.split('.') 

for i in 2.downto(0) do 
    frankly_map("view:'UIPickerView' index:0", 'selectRow:inComponent:animated:', dateParts[i].to_i - 1, i, false) 
end 

因此,我們通過翻轉開關並將其更改爲適當的值。但是,翻轉開關的變化並不反映在UITextBox中。所以我決定通過在UIPickerView任何值攻來更新它:

touch("view marked:'15'") 

但是,這改變了每一個不倒翁!有人能告訴我爲什麼會發生這種情況,以及我如何獲得日期設置?

+0

對於良好的問題格式+1 – ram

回答

0

以下是在Java我沒有選擇從選擇器視圖的值的方法(其使用所選擇的選擇器值的UITextField也被更新,對於必須生成滾動事件):

/** 
* Select row with @rowValue value for @selector UI picker view. 
* 
* @param selector 
* @param rowValue 
* @throws Exception 
*/ 
public static void selectRowFromPicker(String selector, String rowValue) throws Exception { 
    int component = 0; 
    JSONArray rowsCountArray = Frank.frankly_map(selector, "numberOfRowsInComponent:", component); 
    if (rowsCountArray.length() == 0) { 
     throw new Exception("No rows for picker view component " + component + " were found."); 
    } 

    int rowsCount = rowsCountArray.getInt(0); 
    String tableViewSelector = selector + " descendant tableView"; 
    boolean found = false; 
    String initialText = ""; 

    for (int i = 0; i < rowsCount; i++) { 
     JSONArray array = Frank.frankly_map(selector, "selectRow:inComponent:animated:", i, component, true); 
     if (array.length() == 0) { 
      throw new Exception("Could not select row from picker view with row value: '" + rowValue + "' selector: '" + selector + "'"); 
     } 
     String labelSelector = tableViewSelector + " descendant label index:0"; 
     WaitHelper.waitFor(WaitHelper.not(WaitHelper.viewTextToHaveValue(labelSelector, initialText)), GlobalVariables.MEDIUM); 
     JSONArray currentTableViewRowValue = Frank.frankly_map(labelSelector, "text"); 
     if (currentTableViewRowValue.length() == 0) { 
      throw new Exception("Could not get the text for current row for picker view selector: " + selector); 
     } 
     if (currentTableViewRowValue.getString(0).equals(rowValue)) { 
      found = true; 
      break; 
     } 
     initialText = currentTableViewRowValue.getString(0); 
    } 

    //Need to generate a scroll event to bind data in the controls which use the picker selected value 
    if (!Frank.scrollDownRows(tableViewSelector, 0) || !found) { 
     throw new Exception("Could not scroll down in the picker view selector: " + selector); 
    } 
} 

Where Frank.scrollDownRows does:Frank.frankly_map(selector, "scrollDownRows:", noOfRows);

我希望這會有所幫助。