【发布时间】:2014-03-31 09:17:42
【问题描述】:
我尝试使用流布局创建 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 英寸和 IOS 7.1。 我正在使用的代码可以在这里找到:
https://gist.github.com/jhmegorei/42c15038a34971ac5e8e
注意:我不想使用 CollectionViewController,因为我要求集合 View 只是另一个可以添加到普通 UIView 的视图元素。
如果有人可以帮助我调查这次崩溃的根本原因,我会很高兴 :)
【问题讨论】:
-
你在使用类似 [someview addSubview:CollectionViewController.view] 的代码吗?
-
不,正如您在要点中看到的那样,我根本不使用 collectionViewController(据我在 API 文档中阅读,这不是必需的)。在 MemoListView.rb 第 15 行,我将 list_view 添加到视图中。
-
我设法通过将 MemoListViewDelegate.rb 中的方法放入 MemoListView.rb 来使其工作。仍然不喜欢那个解决方案,但至少它有效......
-
Imrael,同样的解决方案对我有用。我想知道这是否是 Ruby Motion 特有的错误。
标签: ios iphone objective-c rubymotion