简体   繁体   English

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

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

I am trying to set a button property like this, When i add this code it crashes without even displaying the button i have in the main.storyboard.我正在尝试设置这样的按钮属性,当我添加此代码时,它甚至没有显示我在 main.storyboard 中的按钮就崩溃了。

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

安慰

From the error, you can see that UIButton does not have a method called applyOutlinedThemeWithScheme , which could mean that in your storyboard or XIB, you are using a UIButton instead of a MDCButton.从错误中,您可以看到UIButton没有名为applyOutlinedThemeWithScheme的方法,这可能意味着在您的故事板或 XIB 中,您使用的是 UIButton 而不是 MDCButton。

In your storyboard or XIB, go to Identity Inspector, make sure Class is set to MDCButton .在您的故事板或 XIB 中,转到 Identity Inspector,确保Class设置为MDCButton

I faced the same problem.我遇到了同样的问题。 But I was building the UI through code.但我是通过代码构建用户界面的。

import MaterialComponents.MaterialButtons
import MaterialComponents.MaterialButtons_Theming

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

The following helped me.以下帮助了我。 I just called the option Product -> Clean Build Folder .我刚刚调用了选项Product -> Clean Build Folder After that, the abnormal termination of the program disappeared.之后,程序异常终止的现象就消失了。

暂无
暂无

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

相关问题 NSInvalidArgumentException,原因无法识别的选择器发送到实例 - NSInvalidArgumentException, reason unrecognized selector sent to instance NSInvalidArgumentException原因:无法识别的选择器发送到实例 - NSInvalidArgumentException reason : unrecognized selector sent to instance initwithNibName:和viewDidLoad之间的“'NSInvalidArgumentException',原因:'-[UIButton intValue]:无法识别的选择器发送到实例” - “'NSInvalidArgumentException', reason: '-[UIButton intValue]: unrecognized selector sent to instance” between initwithNibName: and viewDidLoad 'NSInvalidArgumentException',原因:'-[__ NSCFString encodeString:]:无法识别的选择器已发送到实例 - 'NSInvalidArgumentException', reason: '-[__NSCFString encodeString:]: unrecognized selector sent to instance 未捕获的异常'NSInvalidArgumentException',原因: - [_ SwiftValue floatValue]:无法识别的选择器发送到实例 - Uncaught exception 'NSInvalidArgumentException', reason: -[_SwiftValue floatValue]: unrecognized selector sent to instance NSInvalidArgumentException',原因:' - [__ NSArrayI length:无法识别的选择器发送到实例 - NSInvalidArgumentException', reason: '-[__NSArrayI length : unrecognized selector sent to instance 异常'NSInvalidArgumentException',原因:'-[AnnotationView setCoordinate:]:无法识别的选择器已发送到实例 - exception 'NSInvalidArgumentException', reason: '-[AnnotationView setCoordinate:]: unrecognized selector sent to instance NSInvalidArgumentException',原因:' - [UITableView setSeparatorInset:]:发送到实例的无法识别的选择器 - NSInvalidArgumentException', reason: '-[UITableView setSeparatorInset:]: unrecognized selector sent to instance 'NSInvalidArgumentException',原因:'-[__ NSCFString objectAtIndex:]:无法识别的选择器已发送到实例 - 'NSInvalidArgumentException', reason: '-[__NSCFString objectAtIndex:]: unrecognized selector sent to instance NSInvalidArgumentException',原因:'-[NSNull 长度]:无法识别的选择器发送到实例 - NSInvalidArgumentException', reason: '-[NSNull length]: unrecognized selector sent to instance
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM