首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JTAppleCalendar细胞在TableView?在Swift 3

JTAppleCalendar细胞在TableView?在Swift 3
EN

Stack Overflow用户
提问于 2017-04-24 13:49:05
回答 1查看 582关注 0票数 0

我使用JTAppleCalendar -> https://github.com/patchthecode/JTAppleCalendar日历插件,我想在TableView单元格中放置ColectionView单元格,并且我想用标题显示添加的事件中的每个单元格(在表视图单元格内),但是当我连接插座给我;

错误:非法配置: tableView从ViewController到UITableView的出口无效。插座不能连接到重复内容。

我怎么才能修好它?

CellView.swift

代码语言:javascript
复制
import JTAppleCalendar

class CellView: JTAppleCell {
    @IBOutlet var selectedView: UIView!
    @IBOutlet var dayLabel: UILabel!
    @IBOutlet var Label: UILabel!
}

Cell.Swift

代码语言:javascript
复制
import UIKit

class Cell: UITableViewCell {

    @IBOutlet weak var label : UILabel!

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)


    }
}

ViewController.Swift

代码语言:javascript
复制
@IBOutlet weak var tableView: UITableView!


  extension ViewController: UITableViewDelegate, UITableViewDataSource {

        func numberOfSections(in tableView: UITableView) -> Int {
            return  1
        }

        func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
            return  5
        }

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

            cell.label?.text = String(indexPath.row)

            return cell
        }

        func tableView(_ tableView: UITableView,didSelectRowAt indexPath: IndexPath) {
            tableView.deselectRow(at: indexPath, animated: true)
        }
    }

下面是我的屏幕;

EN

回答 1

Stack Overflow用户

发布于 2017-04-24 13:55:42

您需要创建CollectionViewCell的自定义类并在其上使用IBOutlets。现在,您已经在ViewController类中使用了customCell的视图IBOutlets。

使用tag属性,您可以将该视图与单元格链接。如下面在cellForItemAtIndexPath中所示。

代码语言:javascript
复制
let label:UILabel = cell.viewWithTag(101) as! UILabel // 101 tag need to set in storyboard related view 

如何为查看分配标记

https://stackoverflow.com/a/31782616/3901620

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43589925

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档