Swift: Wie die reload-Zeile-Höhe in UITableViewCell, ohne die Daten neu laden

Ich habe einen Fall, in dem ich erneut laden, nur die Höhe der UITableViewCell.

aber wenn ich die Funktion aufrufen

tableView.reloadRowsAtIndexPaths([NSIndexPath(forRow: webView.tag, inSection: 0)], withRowAnimation: .Automatic)

lädt es die Höhe sowie die Daten der Zelle.
Wie kann ich nur die Höhe der Zelle in Swift?

Dies ist mein cellForRow block :

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    if indexPath.row == 0 {
        let cell = tableView.dequeueReusableCellWithIdentifier("cell1", forIndexPath: indexPath) as! CustomTableViewCell1
    cell.heading.text = headerText
        return cell
    }

    else if indexPath.row == 1 {
        let cell = tableView.dequeueReusableCellWithIdentifier("cell2", forIndexPath: indexPath) as! CustomTableViewCell2
        ImageLoader.sharedLoader.imageForUrl(self.headerImage , completionHandler:{(image: UIImage?, url: String) in
            cell.mainImage.image = image
        })
        return cell
    }
    else if indexPath.row == 2 {
        let cell = tableView.dequeueReusableCellWithIdentifier("cell3", forIndexPath: indexPath) as! CustomTableViewCell3
        //cell.aurthorImage.image = UIImage(named : "obama")
        ImageLoader.sharedLoader.imageForUrl(self.headerImage , completionHandler:{(image: UIImage?, url: String) in
            cell.aurthorImage.image = image
        })
        cell.aurthorImage.tag = aurthorID
        cell.aurthorImage.layer.cornerRadius = cell.aurthorImage.frame.height/2
        cell.aurthorImage.clipsToBounds = true
        cell.aurthorImage.userInteractionEnabled = true
        cell.aurthorImage.addGestureRecognizer(aurthorImageTapRecignizer)
        cell.aurthorName.text = self.authorName
        cell.time.text = self.time
        self.followButton = cell.followButton
        return cell
    }

    else if indexPath.row == 3 {
        let cell = tableView.dequeueReusableCellWithIdentifier("cell4", forIndexPath: indexPath) as! CustomTableViewCell4
        let htmlHeight = contentHeights[indexPath.row]

        cell.webElement.tag = indexPath.row
        cell.webElement.delegate = self
        cell.webElement.loadHTMLString(HTMLContent, baseURL: nil)
        cell.webElement.frame = CGRectMake(0, 0, cell.frame.size.width, htmlHeight)

        return cell
    }
    else if indexPath.row == 4 {
        let cell = tableView.dequeueReusableCellWithIdentifier("cell1", forIndexPath: indexPath) as! CustomTableViewCell1
        cell.heading.text = "Related Posts"
        return cell
    }
    else if indexPath.row == 5{
        let cell = tableView.dequeueReusableCellWithIdentifier("cell6", forIndexPath: indexPath) as! CustomTableViewCell6
        return cell

    }
    else if indexPath.row == 6 {
        let cell = tableView.dequeueReusableCellWithIdentifier("cell1", forIndexPath: indexPath) as! CustomTableViewCell1
        cell.heading.text = "Comments"
        return cell
    }
    else if indexPath.row == 7 {

        let cell = tableView.dequeueReusableCellWithIdentifier("cell5", forIndexPath: indexPath) as! CustomTableViewCell5


        let htmlHeight = contentHeights[indexPath.row]
        self.commentSection = cell.commentsView
        self.commentSection.tag = indexPath.row
        self.commentSection.delegate = self
        let url = NSURL(string: commentsURL)
        let requestObj = NSURLRequest(URL: url! )
        self.commentSection.loadRequest(requestObj)
        self.commentSection.frame = CGRectMake(0, 0, cell.frame.size.width, htmlHeight)
            commentSectionDidNotLoad = false

            return cell
    }
    else {
        let cell = tableView.dequeueReusableCellWithIdentifier("cell1", forIndexPath: indexPath) as! CustomTableViewCell1
        cell.heading.text = headerText
        return cell
    }
  • Sie wollen nicht zum aktualisieren von Daten auf dem reload?
  • ja , die Daten sollten nicht geladen werden
  • Dann müssen Sie die Bedingung über die cellForRow. Aber ich denke, dass, wenn die Daten aktualisiert wird, dann muss sich zu Tisch.
  • Oder, Wenn Sie text-Feld oder sonst irgendwas in dieser Zelle, die Sie haben, um die Daten zu speichern. und danach laden Sie dann Daten wird sich nicht ändern!
  • ja, aber ich bin mit einer webView, die nicht neu geladen werden
  • können Sie Ihre cellForRow code hier. durch die Bearbeitung Ihrer Frage?
  • Vielleicht ein Duplikat der stackoverflow.com/questions/35975444/... ?
  • Warum willst du nicht neu zu laden Daten? In einer Zeit, Wie viele Zeilen, die Sie aktualisieren?
  • Ich brauche zu aktualisieren, die Höhe nur, weil die Zeile enthält ein UIWebView @ParamasivanSamuttiram
  • beginUpdates und endUpdates wird zusammen rufen heightForRowAtIndexPath. Hast du es versucht?
  • Aber Sie werden rufen CellForRowAtIndexPath wie gut, nicht wahr?

Schreibe einen Kommentar