简体   繁体   中英

UICollectionView crash on scroll

I tried to create a UICollectionView using the Flow Layout. The cells are simply text labels for the time being. The first screen of cells is displayed just fine, but when I try to scroll, the simulator crashes. The debugger shows the following messages:

(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

I am using the latest version of rubymotion and the IOS Simulator set to iPhone 4 Inch with IOS 7.1. The code I am using can be found here:

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

Note: I did not want to use a CollectionViewController, as I require the collection View to be just another view element that can be added to a normal UIView.

I would be glad if there is anyone who could help me investigate the root cause of this crash :)

There is no "MemoListViewDelegate.rb" in the gist. Did you mean "MemoListDataSource.rb" ?

Also, I assume you mean you changed

  list_view.dataSource       = MemoListDatasource.new

to

  list_view.dataSource       = self

as well as moving the data source methods in there.

Did you make any other changes to get it to work?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM