简体   繁体   中英

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.

 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.

In your storyboard or XIB, go to Identity Inspector, make sure Class is set to 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 . After that, the abnormal termination of the program disappeared.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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