[英]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.