简体   繁体   中英

UITableView causing crash on iOS7?

This crash is reported by a crash reporting tool, It only happens on iOS7 and I am not able to reproduce.

It seems like something calls scrollView:contentSizeForZoomScale:withProposedSize , the cell contains 2 buttons that resize depending on the data passed to it (no scrollViews, and nowhere a delegate for any UIScrollView is getting set).

Any thoughts on what causes the scrollView delegate method to get called on the cell?

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

EDIT: Implemented that method, and it looks like it's being called by:

<UITableViewCellScrollView: 0x78e39ee0; frame = (0 0; 320 44); autoresize = W+H; gestureRecognizers = <NSArray: 0x78eafc10>; layer = <CALayer: 0x78e354a0>; contentOffset: {0, 0}>

On iOS7 apple made changes to the view hierarchy of a UITableViewCell. In iOS 7 the contntView is embedded in a UIScrollView , and the scrollView on some situations (I haven't figured out when) calls that method on the cell.

The fix was to implement the following method and return the poposedSize. This fix is only needed on iOS7. The viewHierarchy on iOS8+ has been changed to the way it was on iOS6. (No more UIScrollView is used in a tableViewCell hierarchy)

- (CGSize)scrollView:(id)arg1 contentSizeForZoomScale:(float)arg2 withProposedSize:(CGSize)arg3 {
    return arg3;
}

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