繁体   English   中英

MDC 因“NSInvalidArgumentException”而崩溃,原因:“-[UIButton applyOutlinedThemeWithScheme:]: 无法识别的选择器发送到实例

[英]MDC crashing with 'NSInvalidArgumentException', reason: '-[UIButton applyOutlinedThemeWithScheme:]: unrecognized selector sent to instance

我正在尝试设置这样的按钮属性,当我添加此代码时,它甚至没有显示我在 main.storyboard 中的按钮就崩溃了。

 let containerScheme = MDCContainerScheme() cancelButton.applyOutlinedTheme(withScheme: containerScheme)

安慰

从错误中,您可以看到UIButton没有名为applyOutlinedThemeWithScheme的方法,这可能意味着在您的故事板或 XIB 中,您使用的是 UIButton 而不是 MDCButton。

在您的故事板或 XIB 中,转到 Identity Inspector,确保Class设置为MDCButton

我遇到了同样的问题。 但我是通过代码构建用户界面的。

import MaterialComponents.MaterialButtons
import MaterialComponents.MaterialButtons_Theming

let button = MDCButton()
button.applyTextTheme(withScheme: MDCContainerScheme())

以下帮助了我。 我刚刚调用了选项Product -> Clean Build Folder 之后,程序异常终止的现象就消失了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM