此崩溃由崩溃报告工具报告,它只发生在iOS7上,我无法重现。
似乎调用scrollView:contentSizeForZoomScale:withProposedSize
,单元格包含2个按钮,根据传递给它的数据调整大小(没有scrollViews,任何UIScrollView的委托都没有设置)。
有关导致在单元格上调用scrollView委托方法的原因的任何想法吗?
Fatal Exception: NSInvalidArgumentException
-[ProfileContactUserCell scrollView:contentSizeForZoomScale:withProposedSize:]: unrecognized selector sent to instance 0x127592a20
Thread : Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x000000018169b100 __exceptionPreprocess
1 libobjc.A.dylib 0x000000018dba41fc objc_exception_throw
2 CoreFoundation 0x000000018169fdb4 __methodDescriptionForSelector
3 CoreFoundation 0x000000018169dae0 ___forwarding___
4 CoreFoundation 0x00000001815bd78c _CF_forwarding_prep_0
5 UIKit 0x0000000184680d38 -[UIScrollView setFrame:]
6 UIKit 0x000000018467b12c -[UIView(Geometry) _applyAutoresizingMaskWithOldSuperviewSize:]
7 UIKit 0x000000018476ad20 -[UIScrollView _resizeWithOldSuperviewSize:]
8 CoreFoundation 0x00000001815ad1dc __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke
9 CoreFoundation 0x00000001815ad0a8 -[__NSArrayM enumerateObjectsWithOptions:usingBlock:]
10 UIKit 0x000000018466a9f8 -[UIView(Geometry) resizeSubviewsWithOldSize:]
11 UIKit 0x000000018465b9f8 -[UIView(Geometry) setFrame:]
12 UIKit 0x00000001847400d8 -[UITableViewCell setFrame:]
13 UIKit 0x00000001847adf74 __53-[UITableView _configureCellForDisplay:forIndexPath:]_block_invoke
14 UIKit 0x0000000184672de0 +[UIView(Animation) performWithoutAnimation:]
15 UIKit 0x00000001847adcc8 -[UITableView _configureCellForDisplay:forIndexPath:]
16 UIKit 0x00000001847ac90c -[UITableView _createPreparedCellForGlobalRow:withIndexPath:]
17 UIKit 0x000000018474ae4c -[UITableView _updateVisibleCellsNow:]
18 UIKit 0x000000018473d8a4 -[UITableView _visibleCells]
19 UIKit 0x000000018473d768 -[UITableView setSeparatorStyle:]
20 Company 0x00000001000ae7ac -[ProfileViewController viewDidLoad] (ProfileViewController.m:104)
21 UIKit 0x0000000184664658 -[UIViewController loadViewIfRequired]
22 UIKit 0x00000001846643dc -[UIViewController view]
23 UIKit 0x0000000184811850 -[UINavigationController _startCustomTransition:]
24 UIKit 0x000000018471bf3c -[UINavigationController _startDeferredTransitionIfNeeded:]
25 UIKit 0x000000018471bd0c -[UINavigationController __viewWillLayoutSubviews]
26 UIKit 0x000000018471bc8c -[UILayoutContainerView layoutSubviews]
27 UIKit 0x000000018465efe0 -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
28 QuartzCore 0x0000000184250258 -[CALayer layoutSublayers]
29 QuartzCore 0x000000018424ae20 CA::Layer::layout_if_needed(CA::Transaction*)
30 QuartzCore 0x000000018424acd8 CA::Layer::layout_and_display_if_needed(CA::Transaction*)
31 QuartzCore 0x000000018424a560 CA::Context::commit_transaction(CA::Transaction*)
32 QuartzCore 0x000000018424a304 CA::Transaction::commit()
33 UIKit 0x0000000184663154 _UIApplicationHandleEventQueue
34 CoreFoundation 0x000000018165b7f4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
35 CoreFoundation 0x000000018165ab50 __CFRunLoopDoSources0
36 CoreFoundation 0x0000000181658de8 __CFRunLoopRun
37 CoreFoundation 0x0000000181599dd0 CFRunLoopRunSpecific
38 GraphicsServices 0x0000000187281c0c GSEventRunModal
39 UIKit 0x00000001846cafc4 UIApplicationMain
40 Company 0x0000000100072c1c main (main.m:13)
41 libdyld.dylib 0x000000018e197aa0 start
修改 实现了该方法,看起来它被调用:
<UITableViewCellScrollView: 0x78e39ee0; frame = (0 0; 320 44); autoresize = W+H; gestureRecognizers = <NSArray: 0x78eafc10>; layer = <CALayer: 0x78e354a0>; contentOffset: {0, 0}>
答案 0 :(得分:1)
在iOS7上,苹果对UITableViewCell的视图层次结构进行了更改。
在iOS 7中,contntView
嵌入在UIScrollView
中,而滚动查看在某些情况下(我还没弄清楚何时)在单元格上调用该方法。
修复是实现以下方法并返回poposedSize。只有在iOS7上才需要此修复程序。 iOS8 +上的viewHierarchy已经改变为iOS6上的方式。 (在tableViewCell层次结构中不再使用UIScrollView)
- (CGSize)scrollView:(id)arg1 contentSizeForZoomScale:(float)arg2 withProposedSize:(CGSize)arg3 {
return arg3;
}