iOS - 将文本设置为 UILabel 属性的异常
<p><p>我在我的一个 <code>View Controllers</code> 中遇到了一个奇怪的问题,每件事都工作正常并且加载正常,但是 <strong><code>每当我为 View 设置值时,我都会得到一个异常与层相关</code></strong>。但是,我没有在 <strong>Interface Builder</strong> 或代码中为图层设置任何属性。以下是我收到的日志,现在对我来说毫无意义</p>
<pre><code>-: unrecognized selector sent to instance 0x923a4e0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-: 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 - + 275
3 CoreFoundation 0x01ee350b ___forwarding___ + 1019
4 CoreFoundation 0x01ee30ee _CF_forwarding_prep_0 + 14
5 UIKit 0x00a6d463 - + 45
6 UIKit 0x00a6e8c2 - + 70
7 UIKit 0x00a70dfc - + 98
8 UIKit 0x0091f453 - + 504
9 QuartzCore 0x00213f39 - + 123
10QuartzCore 0x00213e6a _ZL16backing_callbackP9CGContextPv + 96
11QuartzCore 0x001024fc CABackingStoreUpdate_ + 2656
12QuartzCore 0x00213e02 ___ZN2CA5Layer8display_Ev_block_invoke + 93
13QuartzCore 0x002482d7 x_blame_allocations + 15
14QuartzCore 0x00213c6d _ZN2CA5Layer8display_Ev + 1519
15QuartzCore 0x00213eb9 - + 33
16QuartzCore 0x00213676 _ZN2CA5Layer7displayEv + 144
17QuartzCore 0x00213e93 - + 33
18QuartzCore 0x00210fb7 - + 57
19QuartzCore 0x002113b1 - + 192
20QuartzCore 0x00213376 - + 413
21QuartzCore 0x002118bc - + 1483
22QuartzCore 0x00213376 - + 413
23QuartzCore 0x002118bc - + 1483
24QuartzCore 0x00213376 - + 413
25QuartzCore 0x002118bc - + 1483
26SilverStar 0x00011fad - + 525
27SilverStar 0x00013005 - + 549
28SilverStar 0x0000c936 - + 438
29libobjc.A.dylib 0x01c02880 - + 77
30UIKit 0x008b23b9 - + 108
31UIKit 0x008b2345 - + 61
32UIKit 0x009b3bd1 - + 66
33UIKit 0x009b3fc6 - + 577
34UIKit 0x009b3243 - + 641
35UIKit 0x00c482e3 _UIGestureRecognizerUpdate + 7166
36UIKit 0x008f1a5a - + 1291
37UIKit 0x008f2971 - + 1021
38UIKit 0x008c45f2 - + 242
39UIKit 0x008ae353 _UIApplicationHandleEventQueue + 11455
40CoreFoundation 0x01e7c77f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
41CoreFoundation 0x01e7c10b __CFRunLoopDoSources0 + 235
42CoreFoundation 0x01e991ae __CFRunLoopRun + 910
43CoreFoundation 0x01e989d3 CFRunLoopRunSpecific + 467
44CoreFoundation 0x01e987eb CFRunLoopRunInMode + 123
45GraphicsServices 0x036c25ee GSEventRunModal + 192
46GraphicsServices 0x036c242b GSEventRun + 104
47UIKit 0x008b0f9b UIApplicationMain + 1225
</code></pre>
<p><strong>注意:我不确定您可能需要哪个代码段。所以,让我知道我会在这里添加问题</strong></p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>您传递的是 <code>NSNumber</code> 而不是 <code>NSString</code>。试试这个:</p>
<pre><code>NSString *myString = ; // aNumber is a NSNumber
self.label.text = myString
</code></pre>
<p>希望这会有所帮助.. :)</p></p>
<p style="font-size: 20px;">关于iOS - 将文本设置为 UILabel 属性的异常,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/23100286/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/23100286/
</a>
</p>
页:
[1]