gpt4 book ai didi

ios - 您不能直接初始化此类 - 在 Storyboard/NIB 文件中,将类类型设置为子类之一

转载 作者:行者123 更新时间:2023-11-28 05:53:38 24 4
gpt4 key购买 nike

我正在使用 SVKit用于显示 SVG 图像。这就是我所做的:

  1. 使用 pod 集成 SVG。
  2. 在我的 UIViewController 中获取一个 UIView(在 Storyboard 中)。
  3. 将其类设置为 SVGKImageView。
  4. 在 viewDidLoad 中:

    self.imageView.image = SVGKImage(named: "my-logo")  

在同一行中,我遇到了崩溃:

Xcode is trying to load this class from a StoryBoard or from a NIB/XIB files. You cannot init this class directly - in your Storyboard/NIB file, set the Class type to one of the subclasses, e.g. SVGKFastImageView'

最佳答案

我知道这不是很明显,但 SVGKImageView 的文档说明如下:

NB: the "SVGKFastImageView" is the one you want 9 times in 10.
The alternative classes (e.g. SVGKLayeredImageView) are for advanced usage.
NB: read the class-comment for each subclass carefully before deciding what to use.

SVKit 的源文件中找到

关于ios - 您不能直接初始化此类 - 在 Storyboard/NIB 文件中,将类类型设置为子类之一,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52060134/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com