Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何在UITableView中使用IBDesignable类_Ios_Swift_Xcode_Ibdesignable - Fatal编程技术网

Ios 如何在UITableView中使用IBDesignable类

Ios 如何在UITableView中使用IBDesignable类,ios,swift,xcode,ibdesignable,Ios,Swift,Xcode,Ibdesignable,我是Swift和Xcode的初学者,我想知道在UITableView中使用IBDesignable类的做法。我在我的类中设计了一张卡片,以便在我的故事板中直接看到结果,但我有一些标签、UIImage和其他组件,我需要在此函数中在UITableView中动态修改: public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cel

我是
Swift
Xcode
的初学者,我想知道在
UITableView
中使用
IBDesignable
类的做法。我在我的类中设计了一张卡片,以便在我的故事板中直接看到结果,但我有一些标签、UIImage和其他组件,我需要在此函数中在
UITableView
中动态修改:

public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! CardCell

    let cardData: Card
    cardData = self.card[indexPath.row]

    // Here I want to catch the card what I design in the class IBDesignableCard to set the IBDesignableCard.label, IBDesignableCard.userImage ...

    return cell // And here return the IBDesignableCard
    }

我怎样才能做到这一点?感谢您的回复。

根据我有限的经验,IBDesignable是一种定制I.B.首先提供的UI元素的方法(InterfaceBuilderDesignable,而不是codeDesignable),例如为按钮或标签提供一定厚度的圆形边框。Ray Wenderlich的网站有一个很好的教程。做起来比解释起来容易。我知道您正在询问组成Tableview的元素,但是您必须从单独的类文件编写规范。到目前为止你找了什么?也许你应该补充一下你的问题。欢迎来到SO和Swift世界。@aremvee感谢您的回复!是的,我想在故事板中预览我的设计,并动态修改我在IBDesign类中构建的内容,但显然我唯一的方法是直接在“普通”类中构建我的卡,并在tableView函数中调用它。