Ios 在uitableview中显示更多信息

Ios 在uitableview中显示更多信息,ios,swift,uitableview,Ios,Swift,Uitableview,默认情况下,每个部分最多应显示三个单元格。如果任何单元格包含三个以上的单元格,则应显示“显示更多”选项。如果点击“显示更多”,则我希望在该特定部分显示其余单元格。我花了两天的时间,什么也没做。片段在桌子的顶端。根据选定的线段,tableview加载单元格。每个部分的每个段的代码都不同,因此funccellforrowatinexpath:变得非常大。我粗略地添加了代码。这是我尝试过的代码 if segmentName == .Feature || segmentName == .Services

默认情况下,每个部分最多应显示三个单元格。如果任何单元格包含三个以上的单元格,则应显示“显示更多”选项。如果点击“显示更多”,则我希望在该特定部分显示其余单元格。我花了两天的时间,什么也没做。片段在桌子的顶端。根据选定的线段,tableview加载单元格。每个部分的每个段的代码都不同,因此func
cellforrowatinexpath:
变得非常大。我粗略地添加了代码。这是我尝试过的代码

if segmentName == .Feature || segmentName == .Services
    {
        if indexPath.section == 0
        {
            if boolShowFullFeature[indexPath.section] == false
            {
                if indexPath.row == showCells
                {
                    return createShowMoreCell(indexPath.section)
                }
                else
                {
                    let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! SearchListViewCell
                    var firstTitle = "", secondTitle = "", thirdTitle = "", recomendValue = "", starValue = ""

                    (firstTitle, secondTitle, thirdTitle, recomendValue, starValue) = model.foodValue[indexPath.row]
                    cell.configureCell(firstTitle, secondTitle: secondTitle, thirdTitle: thirdTitle, recomendValue: recomendValue, starValue: starValue)
                    return cell

我以前确实做过这件事。以下是示例代码:

var objects = [["1","2","3"],["q","w","e","r","t","y"],["z","x","c","v","b","n","m"]]
var sec = ["sec a","sec b","sec c"]
var showallSec = 0

override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
    return sec.count
}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    let items = objects[section].count

    if items > 3{
        if section == showallSec-1{
            return items
        }
        return 4
        }
    return items
}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)

    let object = objects[indexPath.section][indexPath.row]
    cell.textLabel!.text = object
    if(indexPath.section != showallSec-1){
    if(indexPath.row == 3){
        cell.textLabel!.text = "show more"
        }}
    return cell
}

override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
    return sec[section]
}

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    if(indexPath.row == 3){
        showallSec = indexPath.section + 1  
        tableView.reloadData()
    }
}

这是一些有趣的信息。你还有问题吗?@Antony你试过什么?有什么效果吗?“什么没有?”达斯多姆说。通知我的好方法…-)@我已经编辑了这个问题。