BUTTON SHAPE on in device (iPhone) setting result

2019-02-26 09:00发布

问题:

Recently i switch my app to iOS 7 compatibility and the app working fine but if i switched on the Button Shape option (Available in iOS 7.1) in device setting (Setting--> Accessblity--> Button shape switch) then app crash and gives following error:-

-[NSAttributeDictionary textContainerForAttributedString:containerSize:lineFragmentPadding:]: unrecognized selector sent to instance 0x17e4e310 CoreFoundation

And the app work fine when button shape option switched off.

crash stack trace:-

-[NSAttributeDictionary textContainerForAttributedString:containerSize:lineFragmentPadding:]: unrecognized selector sent to instance 0x17e4e310
CoreFoundation

Occurrences7
Users2
#   Binary Image Name   Address Symbol
0   CoreFoundation  0x2f057f0b  
1   libobjc.A.dylib 0x397eece7  objc_exception_throw
2   CoreFoundation  0x2f05b837  
3   CoreFoundation  0x2f05a137  
4   CoreFoundation  0x2efa9098  _CF_forwarding_prep_0
5   UIFoundation    0x36cd7915  __NSStringDrawingEngine
6   UIFoundation    0x36cd4863  -[NSString(NSExtendedStringDrawing) drawWithRect:options:attributes:context:]
7   UIKit   0x318a02c9  -[UILabel _drawTextInRect:baselineCalculationOnly:]
8   UIKit   0x31906709  -[UILabel drawTextInRect:]
9   UIKit   0x3190650b  -[UILabel drawRect:]
10  UIKit   0x319064a9  -[UIView(CALayerDelegate) drawLayer:inContext:]
11  QuartzCore  0x31532189  -[CALayer drawInContext:]
12  QuartzCore  0x3151bc5b  CABackingStoreUpdate_
13  QuartzCore  0x315f7c1d  ___ZN2CA5Layer8display_Ev_block_invoke
14  QuartzCore  0x3151b50b  x_blame_allocations
15  QuartzCore  0x3151b1bf  _ZN2CA5Layer8display_Ev
16  QuartzCore  0x314fed41  _ZN2CA5Layer17display_if_neededEPNS_11TransactionE
17  QuartzCore  0x314fe9d9  _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE
18  QuartzCore  0x314fe3e5  _ZN2CA7Context18commit_transactionEPNS_11TransactionE
19  QuartzCore  0x314fe1f7  _ZN2CA11Transaction6commitEv
20  QuartzCore  0x3152b8e3  _ZN2CA11Transaction14release_threadEPv
21  libsystem_pthread.dylib 0x39e096d1  
22  libsystem_pthread.dylib 0x39e09453  
23  libsystem_pthread.dylib 0x39e0a1b9  pthread_exit
24  Foundation  0x2f994703  +[NSThread exit]
25  Foundation  0x2fa40a2d  __NSThread__main__
26  libsystem_pthread.dylib 0x39e0a959  
27  libsystem_pthread.dylib 0x39e0a8cb  _pthread_start
28  libsystem_pthread.dylib 0x39e08ae8  thread_start

Any suggestion Thanks

回答1:

This is usually happening because of the incompatiblity of some code in iOS 7.1.

And this must be happening in the device and not in simulator. Right?

The fact that Simulator runs on different hardware (the underlying Mac OS) versus the device's hardware can mean there are some occasional differences like these.

What you can do is put an "Exception Breakpoint" to find out which method is giving this error. Once you get the method, all you need to do is call that method in the main thread.

You can use :

dispatch_async(dispatch_get_main_queue(), ^{
  [self doSomething];
});

This should do the trick. Hope this helps. Thanks. :)