2014-09-08 4 views
2

Calabash ios에는 각 셀 셀에 대해 작업을 수행하는 each_cell 메서드가 있습니다.UICollectionView 쿼리

each_cell(:query => "tableView", :animate => false, :post_scroll => 0.1) do |row, sec| 
touch("tableViewCell indexPath:#{row},#{sec}") 
tap "back_button" 
end 

는 내가 같은 코드

each_cell(:query => "collectionView", :animate => false, :post_scroll => 0.1) do |row, sec| 
touch("collectionViewCell indexPath:#{row},#{sec}") 
tap "back_button" 
end 

을 사용하려고 다음, 콜렉션 뷰를 가지고 그러나 그것은 작동하지 않는이 오류 가지고 :

NoMethodError: undefined method `times' for "*":String

그래서 나는이를 생각한다을 함수는 케이터 테이블 뷰로 만 제한 될 수 있습니까? 컬렉션보기에서 각 셀에 작업을 수행하는 방법에 대한 아이디어가 있습니까? 감사! 내가 무슨 짓을했는지

답변

-1

이었다 ...

  1. 유사한 each_item라는 함수를 만듭니다

    def each_item(opts={:query => 'UICollectionView', :post_scroll => 2, :animate => true}, &block) 
        uiquery = opts[:query] || 'UICollectionView' 
        check_element_exists(uiquery) 
        secs = query(uiquery,:numberOfSections).first 
        secs.times do |sec| 
        items = query(uiquery,{:numberOfItemsInSection => sec}).first 
        items.times do |item_pos| 
         scroll_to_collection_view_item(item_pos, sec, opts) 
         sleep(opts[:post_scroll]) if opts[:post_scroll] and opts[:post_scroll] > 0 
        yield(item_pos, sec) 
        end 
        end 
    end  
    
  2. each에이 옵션을 사용하려면이

    each_item do |item_pos, section_number| 
        # YOUR CODE HERE 
        # to use the query with collection view item 
        # query("<HERE USE YOUR CUSTOM CLASS OF THE ITEMS IN THE CELLS> indexPath:#{item_pos},#{section_number}") 
    end 
    
  3. 과 같은 작업을 수행 할 수 있습니다
+0

그래서, 질문은 무엇입니까? – nlips