Crash when create a new JGActionSheetSection
I met a crash recently, and from the Fabric the detail is (iPhone 6s, iOS9.2.1):
Thread : Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x1829edbd0 objc_msgSend + 16
1 Foundation 0x183c428e4 -[NSObject(NSKeyValueObserverNotification) willChangeValueForKey:] + 324
2 QuartzCore 0x185a5f374 CA::Layer::set_delegate(objc_object*) + 72
3 UIKit 0x188062538 -[UIView _createLayerWithFrame:] + 580
4 UIKit 0x188061ff8 UIViewCommonInitWithFrame + 688
5 UIKit 0x188061ce8 -[UIView initWithFrame:] + 140
6 UIKit 0x1880695b8 -[UILabel initWithFrame:] + 48
7 UIKit 0x1881278d8 -[UIButtonLabel _initWithFrame:button:] + 104
8 UIKit 0x18812778c -[UIButton _newLabelWithFrame:] + 92
9 UIKit 0x18851f0f8 -[UIButton _setupTitleViewRequestingLayout:] + 104
10 UIKit 0x188129304 -[UIButton titleLabel] + 48
11 XXXXXXXXXX 0x100116728 -[JGActionSheetSection setButtonStyle:forButton:] (JGActionSheet.m:395)
12 XXXXXXXXXX 0x1001169b4 -[JGActionSheetSection makeButtonWithTitle:style:] (JGActionSheet.m:414)
13 XXXXXXXXXX 0x1001159e4 -[JGActionSheetSection initWithTitle:message:buttonTitles:buttonStyle:] (JGActionSheet.m:245)
14 XXXXXXXXXX 0x100115568 +[JGActionSheetSection sectionWithTitle:message:buttonTitles:buttonStyle:] (JGActionSheet.m:202)
15 XXXXXXXXXX 0x1000c092c -[ZZFileViewController p_importAction:] (ZZFileViewController.m:525)
16 UIKit 0x188097e50 -[UIApplication sendAction:to:from:forEvent:] + 100
17 UIKit 0x18821b4a4 -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 168
18 UIKit 0x188097e50 -[UIApplication sendAction:to:from:forEvent:] + 100
19 UIKit 0x188097dcc -[UIControl sendAction:to:forEvent:] + 80
20 UIKit 0x18807fa88 -[UIControl _sendActionsForEvents:withEvent:] + 416
21 UIKit 0x18807fbd4 -[UIControl _sendActionsForEvents:withEvent:] + 748
22 UIKit 0x1880976e4 -[UIControl touchesEnded:withEvent:] + 572
23 UIKit 0x188097314 -[UIWindow _sendTouchesForEvent:] + 804
24 UIKit 0x18808fe30 -[UIWindow sendEvent:] + 784
25 UIKit 0x1880604cc -[UIApplication sendEvent:] + 248
26 UIKit 0x18805e794 _UIApplicationHandleEventQueue + 5528
27 CoreFoundation 0x183324efc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
28 CoreFoundation 0x183324990 __CFRunLoopDoSources0 + 540
29 CoreFoundation 0x183322690 __CFRunLoopRun + 724
30 CoreFoundation 0x183251680 CFRunLoopRunSpecific + 384
31 GraphicsServices 0x184760088 GSEventRunModal + 180
32 UIKit 0x1880c8d90 UIApplicationMain + 204
33 XXXXXXXXXX 0x1000dbee8 main (main.m:14)
34 libdispatch.dylib 0x182df28b8 (Missing)
It is crashed in the Main thread, and what I do is create a JGActionSheetSection. The crash seems to happen at
button.titleLabel.font = font;
button is released when label is set to button(right?). My Project enables ARC, and I can't find any memory problem. Could you take a look?
Are you passing a valid value as button style?
what I call is like:
JGActionSheetSection *sectionNonFA = [JGActionSheetSection sectionWithTitle:nil message:nil buttonTitles:actionArray buttonStyle:JGActionSheetButtonStyleDefault];
where actionArray is a array of String.
I got a similar crash Once set font to btn.titleLabel.font crash coming
0 libobjc.A.dylib objc_msgSend (in libobjc.A.dylib) + 16
1 CoreFoundation -[__NSSetM addObject:] (in CoreFoundation) + 332
2 UIKit UIViewDidSetNeedsDisplay (in UIKit) + 100
3 UIKit -[UILabel setNeedsDisplay] (in UIKit) + 64
4 UIKit -[UIView _createLayerWithFrame:] (in UIKit) + 936
5 UIKit UIViewCommonInitWithFrame (in UIKit) + 736
6 UIKit -[UIView initWithFrame:] (in UIKit) + 148
7 UIKit -[UILabel initWithFrame:] (in UIKit) + 48
8 UIKit -[UIButtonLabel _initWithFrame:button:] (in UIKit) + 104
9 UIKit -[UIButton _newLabelWithFrame:] (in UIKit) + 92
10 UIKit -[UIButton _setupTitleViewRequestingLayout:] (in UIKit) + 104
11 UIKit -[UIButton titleLabel] (in UIKit) + 48