相关疑难解决方法(0)

致命错误:对 Swift 类使用未实现的初始化程序 'init()'

我正在使用 [MarkdownTextView][1] 将基本降价添加到UITextView. 该TextView是的子类MarkdownTextView

但是,当使用复制和粘贴时,我收到以下错误

致命错误:对 MarkdownTextStorage 类使用未实现的初始化程序“init()”

这就是我在 ViewController 中使用 TextStorage 的方式

let fonty = UIFont(name: font, size: fsize)
    
attributes.defaultAttributes[NSFontAttributeName] = fonty
attributes.orderedListAttributes?[NSFontAttributeName] = fonty
attributes.orderedListItemAttributes?[NSFontAttributeName] = fonty
attributes.unorderedListAttributes?[NSFontAttributeName] = fonty
attributes.unorderedListItemAttributes?[NSFontAttributeName] = fonty

let textStorage = MarkdownTextStorage(attributes: attributes)
    
do {
   textStorage.addHighlighter(try LinkHighlighter())
} catch let error {
    fatalError("Error initializing LinkHighlighter: \(error)")
}
   textStorage.addHighlighter(MarkdownStrikethroughHighlighter())
   textStorage.addHighlighter(MarkdownSuperscriptHighlighter())
    
if let codeBlockAttributes = attributes.codeBlockAttributes {
        textStorage.addHighlighter(MarkdownFencedCodeHighlighter(attributes: codeBlockAttributes))
 }
Run Code Online (Sandbox Code Playgroud)

我使用了以下初始化程序,但仍然没有运气

required public init?(coder aDecoder: NSCoder) {
    attributes = …
Run Code Online (Sandbox Code Playgroud)

textview ios swift

2
推荐指数
1
解决办法
2452
查看次数

标签 统计

ios ×1

swift ×1

textview ×1