objective-c - iOS 10.3.3 UIButton _intrinsicSizeWithinSize/_updateTitleView CoreFoundation 崩溃

标签 objective-c swift3 crash uibutton ios10.3

我从一些 iOS 10.3.3 用户处随机获取此堆栈跟踪:

-[_TtGCs26_SwiftDeferredNSDictionarySSP__ length]: unrecognized selector sent to instance 0x174421880

Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x183416fe0 __exceptionPreprocess
1  libobjc.A.dylib                0x181e78538 objc_exception_throw
2  CoreFoundation                 0x18341def4 __methodDescriptionForSelector
3  CoreFoundation                 0x18341af54 ___forwarding___
4  CoreFoundation                 0x183316d4c _CF_forwarding_prep_0
5  UIKit                          0x189a437d0 -[UIButton _updateTitleView]
6  UIKit                          0x1895bf828 -[UIButton tintColorDidChange]
7  UIKit                          0x189a5d9d8 -[_UITintColorVisitor _visitView:]
8  UIKit                          0x189a5e0bc _UIViewVisitorEntertainVisitors
9  UIKit                          0x189a5d1f0 _UIViewVisitorRecursivelyEntertainDescendingVisitors
10 UIKit                          0x189a5d2a0 _UIViewVisitorRecursivelyEntertainDescendingVisitors
11 UIKit                          0x189a5cb3c _UIViewVisitorEntertainDescendingTrackingVisitors
12 UIKit                          0x1895445a8 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke
13 Foundation                     0x183e51abc -[NSISEngine withBehaviors:performModifications:]
14 UIKit                          0x1895443b0 -[UIView(Hierarchy) _postMovedFromSuperview:]
15 UIKit                          0x1895502ac -[UIView(Internal) _addSubview:positioned:relativeTo:]
16 UIKit                          0x18954fbc8 -[UIView(Hierarchy) addSubview:]
17 UIKit                          0x18982d81c -[UIView _setTraitStorageSubviews:]
18 Foundation                     0x183e2c68c -[NSObject(NSKeyValueCoding) setValue:forKey:]
19 UIKit                          0x189846b78 -[UIView(CALayerDelegate) setValue:forKey:]
20 UIKit                          0x1899ccb50 -[_UIRelationshipTraitStorage applyRecordsMatchingTraitCollection:]
21 UIKit                          0x1899cb500 -[NSObject(_UITraitStorageAccessors) _applyTraitStorageRecordsForTraitCollection:]
22 UIKit                          0x189831364 -[UIView _traitCollectionDidChangeFromOldCollection:toNewCollection:scaleDidChange:]
23 UIKit                          0x189831488 -[UIView _wrappedProcessDidChangeRecursivelyFromOldTraits:toCurrentTraits:scaleDidChange:forceNotification:]
24 UIKit                          0x189ea84c8 -[UIView(AdditionalLayoutSupport) _withUnsatisfiableConstraintsLoggingSuspendedIfEngineDelegateExists:]
25 UIKit                          0x1898316ec -[UIView _processDidChangeRecursivelyFromOldTraits:toCurrentTraits:forceNotification:]
26 UIKit                          0x189545c50 -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
27 QuartzCore                     0x186736274 -[CALayer layoutSublayers]
28 QuartzCore                     0x18672ade8 CA::Layer::layout_if_needed(CA::Transaction*)
29 QuartzCore                     0x18672aca8 CA::Layer::layout_and_display_if_needed(CA::Transaction*)
30 QuartzCore                     0x1866a634c CA::Context::commit_transaction(CA::Transaction*)
31 QuartzCore                     0x1866cd3ac CA::Transaction::commit()
32 QuartzCore                     0x1866cde78 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*)
33 CoreFoundation                 0x1833c49a8 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
34 CoreFoundation                 0x1833c2630 __CFRunLoopDoObservers
35 CoreFoundation                 0x1833c2a7c __CFRunLoopRun
36 CoreFoundation                 0x1832f2da4 CFRunLoopRunSpecific
37 GraphicsServices               0x184d5d074 GSEventRunModal
38 UIKit                          0x1895adc9c UIApplicationMain
39 <myapp>                          0x10006bf9c main (main.m:14)
40 libdyld.dylib                  0x18230159c start

对于某些用户 -[UIButton _intrinsicSizeWithinSize:] 被替换为 -[UIButton_updateTitleView]

该应用同时使用 Objective-C 和 Swift 3。

我无法在我的设备/模拟器上重现崩溃。

不幸的是,我没有关于该问题的任何其他信息。

有人遇到过类似的问题吗?

TIA

最佳答案

我终于找到问题的根源了!

可以使用以下代码实现崩溃

NSArray *array = @[
    @{@"key": @1, @"name": @"Name1"},
    @{@"key": @2, @"name": @"Name2"},
    @{@"key": @3, @"name": @"Name3"}
];
NSString *title = array[1];
[button setTitle: title forState: UIControlStateNormal];

我正在分配NSDictionary @{@"key": @2, @"name": @"Name2"}title (没有任何警告),然后我通过了 NSDictionary作为NSString[UIButton setTitle:forState:]方法。

我解决了重新定义 array 的问题作为

NSArray<NSDictionary<NSString *, id> *> *array;

并更改我分配给 title 的值来自array[1]array[1][@"name"] .

关于objective-c - iOS 10.3.3 UIButton _intrinsicSizeWithinSize/_updateTitleView CoreFoundation 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45732267/

相关文章:

cocoa - 处理 Swift 3 中 (NS)URLSession 的 cocoa 错误

swift - 付款意向 Sirikit 仍然无法正常工作

ios - 可拖动的 UIView Swift 3

haskell - GHC 可以警告使用危险的非全功能吗?

iphone - ERROR : You are not the current participant. 当我是当前参与者时。什么?

ios - Cocoapods 未正确链接私有(private)框架 Pod

ios - Objective-C 中全局 C 常量的正确声明

ios - OBJ-C 操作指南 : App using BLE connection and iBeacon in same device

安卓应用崩溃

macos - 由于 iCloud,Mac App 在审核中崩溃,但无法在本地测试 iCloud。我能做些什么?