2014-03-31 53 views
1

我試圖使用流佈局來創建一個UICollectionView。 這些單元格暫時只是文本標籤。 單元格的第一個屏幕顯示得很好,但當我嘗試滾動時,模擬器崩潰。 調試器顯示以下信息:UICollectionView滾動崩潰

(lldb) thread backtrace 
    * thread #1: tid = 0x39235a, 0x008440b2 libobjc.A.dylib`objc_msgSend + 14, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xa000000c) 
    * frame #0: 0x008440b2 libobjc.A.dylib`objc_msgSend + 14 
    frame #1: 0x01ab9b30 UIKit`-[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:] + 257 
    frame #2: 0x01abb775 UIKit`-[UICollectionView _updateVisibleCellsNow:] + 4730 
    frame #3: 0x01abf65f UIKit`-[UICollectionView layoutSubviews] + 265 
    frame #4: 0x014e2964 UIKit`-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355 
    frame #5: 0x0084682b libobjc.A.dylib`-[NSObject performSelector:withObject:] + 70 
    frame #6: 0x0280e45a QuartzCore`-[CALayer layoutSublayers] + 148 
    frame #7: 0x02802244 QuartzCore`CA::Layer::layout_if_needed(CA::Transaction*) + 380 
    frame #8: 0x028020b0 QuartzCore`CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 26 
    frame #9: 0x027687fa QuartzCore`CA::Context::commit_transaction(CA::Transaction*) + 294 
    frame #10: 0x02769b85 QuartzCore`CA::Transaction::commit() + 393 
    frame #11: 0x0276a258 QuartzCore`CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 92 
    frame #12: 0x02bd936e CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30 
    frame #13: 0x02bd92bf CoreFoundation`__CFRunLoopDoObservers + 399 
    frame #14: 0x02bb7254 CoreFoundation`__CFRunLoopRun + 1076 
    frame #15: 0x02bb69d3 CoreFoundation`CFRunLoopRunSpecific + 467 
    frame #16: 0x02bb67eb CoreFoundation`CFRunLoopRunInMode + 123 
    frame #17: 0x05f5b5ee GraphicsServices`GSEventRunModal + 192 
    frame #18: 0x05f5b42b GraphicsServices`GSEventRun + 104 
    frame #19: 0x01473f9b UIKit`UIApplicationMain + 1225 
    frame #20: 0x0002423c 8actions`main(argc=1, argv=0xbfffe610) + 156 at main.mm:15 

我使用的是最新版本的rubymotion和IOS模擬器設置爲iPhone 4英寸,7.1 IOS。 我使用的代碼可以在這裏找到:

https://gist.github.com/jhmegorei/42c15038a34971ac5e8e

注:我不想使用CollectionViewController,因爲我需要收集視圖中只可以添加到一個正常的另一視圖元素UIView的。

,如果有任何人誰可以幫我研究這個崩潰:)

+0

你使用的代碼就像[someview addSubview:CollectionViewController.view]? – jnix

+0

不,因爲你可以在要點中看到,我根本不使用collectionViewController(就我所讀的API文檔而言,沒有要求)。 在MemoListView.rb第15行中,我將list_view添加到視圖中。 – Imrael

+1

我設法通過將MemoListViewDelegate.rb中的方法放入MemoListView.rb中來實現它。仍然不喜歡這種解決方案,但至少它的工作原理... – Imrael

回答

0

沒有「MemoListViewDelegate.rb」的宗旨的根本原因,我會很高興。你的意思是「MemoListDataSource.rb」?

另外,我假定你的意思是你改變

list_view.dataSource  = MemoListDatasource.new 

list_view.dataSource  = self 

以及移動中存在的數據源的方法。

你做了任何其他更改讓它起作用嗎?

+0

是的,我的意思是數據源,對於錯字很抱歉。 我重構了所有的東西,我不記得我做的所有工作^^但atm所有我的集合視圖工作正常:D – Imrael