簡體   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