简体   繁体   English

带有表视图节页眉和页脚的注释控制器

[英]Comment controller with table view section header and footer

在此处输入图片说明

How can I achieve this screen with UITableViewCell and UITableViewController. 如何使用UITableViewCell和UITableViewController实现此屏幕。 With table section and header. 带有表节和标题。 Some ideas to achieve this?? 一些实现这一目标的想法? Thanks! 谢谢!

What have you tried so far? 你试过什么了? Your question seems a little broad. 您的问题似乎有点宽泛。

You will need a set of custom UITableViewCell Subclasses, which you design in nibs. 您将需要一组在nibs中设计的自定义UITableViewCell子类。

To make the cells seem apart from each other, resize the content size of the Cells, and make the cell background another color. 若要使单元格看起来彼此分开,请调整单元格的内容大小,并使单元格背景为另一种颜色。

Create a Segmented Control and add it to the Tableviews HeaderView. 创建一个分段控件并将其添加到Tableviews HeaderView。

For the FooterView it seems like this is some kind of subclassed Tabbar. 对于FooterView,似乎这是某种子类的Tabbar。 Easiest way to customise it in such a way, would be to create a View, and add buttons to it. 以这种方式自定义的最简单方法是创建一个View,然后向其中添加按钮。 Add this View as Subview to your TableViewController. 将此视图作为子视图添加到TableViewController。

Have 2 UITableViewCell's one for each type ie 1 for showing the image and text and another for showing just the text. 每个类型有2个UITableViewCell,即1个用于显示图像和文本,另一个用于仅显示文本。

Then in the cellForRowAt delegate method determine which to type to use based off the object you are data binding it to. 然后,在cellForRowAt委托方法中,根据要将数据绑定到的对象,确定要使用的类型。

Example: 例:

public final func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let customObject = customObjects[indexPath.section]

    switch customObject.type {
    case .imageAndText:

        if let cell = tableView.dequeueReusableCell(withIdentifier: ImageAndTextCell.identifier, for: indexPath) as? ImageAndTextCell {
            cell.customObject = customObject
            return cell
        }
    case .text:

        if let cell = tableView.dequeueReusableCell(withIdentifier: TextCell.identifier, for: indexPath) as? TextCell {
            cell.customObject = customObject
            return cell
        }
    }

    return UITableViewCell()
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM