gpt4 book ai didi

iOS - UILabel 属性的异常设置文本

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:23:53 26 4
gpt4 key购买 nike

我在我的一个 View Controllers 中遇到了一个奇怪的问题,每件事都工作正常并且加载正常但是每当我为 View 设置一个值时我得到一个异常层相关。但是,我没有在 Interface Builder 或代码中为 Layer 设置任何属性。下面是我收到的日志,现在对我来说毫无意义

-[__NSCFNumber length]: unrecognized selector sent to instance 0x923a4e0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber length]: unrecognized selector sent to instance 0x923a4e0'
*** First throw call stack:
(
0 CoreFoundation 0x01ef31e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01bf08e5 objc_exception_throw + 44
2 CoreFoundation 0x01f90243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x01ee350b ___forwarding___ + 1019
4 CoreFoundation 0x01ee30ee _CF_forwarding_prep_0 + 14
5 UIKit 0x00a6d463 -[UILabel _shadow] + 45
6 UIKit 0x00a6e8c2 -[UILabel drawTextInRect:] + 70
7 UIKit 0x00a70dfc -[UILabel drawRect:] + 98
8 UIKit 0x0091f453 -[UIView(CALayerDelegate) drawLayer:inContext:] + 504
9 QuartzCore 0x00213f39 -[CALayer drawInContext:] + 123
10 QuartzCore 0x00213e6a _ZL16backing_callbackP9CGContextPv + 96
11 QuartzCore 0x001024fc CABackingStoreUpdate_ + 2656
12 QuartzCore 0x00213e02 ___ZN2CA5Layer8display_Ev_block_invoke + 93
13 QuartzCore 0x002482d7 x_blame_allocations + 15
14 QuartzCore 0x00213c6d _ZN2CA5Layer8display_Ev + 1519
15 QuartzCore 0x00213eb9 -[CALayer _display] + 33
16 QuartzCore 0x00213676 _ZN2CA5Layer7displayEv + 144
17 QuartzCore 0x00213e93 -[CALayer display] + 33
18 QuartzCore 0x00210fb7 -[CALayer displayIfNeeded] + 57
19 QuartzCore 0x002113b1 -[CALayer renderInContext:] + 192
20 QuartzCore 0x00213376 -[CALayer _renderSublayersInContext:] + 413
21 QuartzCore 0x002118bc -[CALayer renderInContext:] + 1483
22 QuartzCore 0x00213376 -[CALayer _renderSublayersInContext:] + 413
23 QuartzCore 0x002118bc -[CALayer renderInContext:] + 1483
24 QuartzCore 0x00213376 -[CALayer _renderSublayersInContext:] + 413
25 QuartzCore 0x002118bc -[CALayer renderInContext:] + 1483
26 SilverStar 0x00011fad -[UIView(ABExtras) imageInNavController:] + 525
27 SilverStar 0x00013005 -[CubeNavigationController pushViewController:animated:] + 549
28 SilverStar 0x0000c936 -[MSArticleViewController detailsbuttonTapped:] + 438
29 libobjc.A.dylib 0x01c02880 -[NSObject performSelector:withObject:withObject:] + 77
30 UIKit 0x008b23b9 -[UIApplication sendAction:to:from:forEvent:] + 108
31 UIKit 0x008b2345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
32 UIKit 0x009b3bd1 -[UIControl sendAction:to:forEvent:] + 66
33 UIKit 0x009b3fc6 -[UIControl _sendActionsForEvents:withEvent:] + 577
34 UIKit 0x009b3243 -[UIControl touchesEnded:withEvent:] + 641
35 UIKit 0x00c482e3 _UIGestureRecognizerUpdate + 7166
36 UIKit 0x008f1a5a -[UIWindow _sendGesturesForEvent:] + 1291
37 UIKit 0x008f2971 -[UIWindow sendEvent:] + 1021
38 UIKit 0x008c45f2 -[UIApplication sendEvent:] + 242
39 UIKit 0x008ae353 _UIApplicationHandleEventQueue + 11455
40 CoreFoundation 0x01e7c77f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
41 CoreFoundation 0x01e7c10b __CFRunLoopDoSources0 + 235
42 CoreFoundation 0x01e991ae __CFRunLoopRun + 910
43 CoreFoundation 0x01e989d3 CFRunLoopRunSpecific + 467
44 CoreFoundation 0x01e987eb CFRunLoopRunInMode + 123
45 GraphicsServices 0x036c25ee GSEventRunModal + 192
46 GraphicsServices 0x036c242b GSEventRun + 104
47 UIKit 0x008b0f9b UIApplicationMain + 1225

注意:我不确定您可能需要哪个代码部分。所以,让我知道我会在这里添加问题

最佳答案

您正在传递 NSNumber 而不是 NSString。试试这个:

NSString *myString = [aNumber stringValue]; // aNumber is a NSNumber
self.label.text = myString

希望这会有所帮助..:)

关于iOS - UILabel 属性的异常设置文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23100286/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com