SWIFTUI 键盘 - 对象不能为零(键:NSColor)'以 NSException 类型的未捕获异常终止

问题描述 投票:0回答:1

当我点击文本框时出现错误

2022-08-18 15:03:58.879060+0300 SecondPhone[16453:505402] Successfully load keyboard extensions
dyld4 config: DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: NSColor)'
terminating with uncaught exception of type NSException
2022-08-18 15:03:59.062946+0300 SecondPhone[16453:505402] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: NSColor)'
*** First throw call stack:
(0x1804c7d1c 0x197ce7ee4 0x1805c26b4 0x1805cc9f8 0x1804800b4 0x18327f734 0x18327d5e4 0x180472998 0x180489504 0x182e00ec4 0x182bdb72c 0x182bd7db4 0x182b8f7e4 0x1069a0700 0x1069a1fc8 0x1069b08ac 0x1069b04fc 0x1804830d4 0x1804405f8 0x180453250 0x1a0f8e988 0x182c53a94 0x1829ecfd4 0x102e2f604 0x105d904d0)
libc++abi: terminating with uncaught exception of type NSException
(lldb) 

快速UI iOS 15 Xcode 13.4.1

enter image description here

swift uikit
1个回答
1
投票

我发现问题了

let attrs = [
        NSAttributedString.Key.foregroundColor: Color.codGray,
        NSAttributedString.Key.font: Font.regularTitle3
    ] as [NSAttributedString.Key : Any]
    UINavigationBar.appearance().titleTextAttributes = attrs

我删除 // NSAttributedString.Key.foregroundColor: Color.codGray

© www.soinside.com 2019 - 2024. All rights reserved.