swift tableviewcell中的文本在滚动时消失

时间:2015-01-24 03:44:00

标签: ios uitableview swift

我遇到了一个奇怪的问题。我有一个非常简单的表视图控制器在swift中,大多数情况下它工作,加载等。它在一个部分中有一行,单元格中的文本数量使得单元格长于tableView所在的UIView当我向上滚动单元格以读取视图边缘下方的文本时,文本消失,tableView填充空的正常高度行。这是我的代码:

import Foundation
import UIKit
import SpriteKit

class WelcomeTVC: UITableViewController {

    init(dictString: String) {
        super.init(style: UITableViewStyle.Plain)
        self.view.backgroundColor = UIColor.clearColor()
    }

    override init() {
        super.init(style: UITableViewStyle.Plain)
        self.view.backgroundColor = UIColor.clearColor()
    }

    required init(coder aDecoder: NSCoder) {
        // Or call super implementation
        fatalError("NSCoding not supported")
    }

    private override init(nibName nibNameOrNil: String!, bundle nibBundleOrNil: NSBundle!) {
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        tableView.estimatedRowHeight = 89
        tableView.rowHeight = UITableViewAutomaticDimension

        tableView.allowsSelection = false
        //tableView.separatorStyle = UITableViewCellSeparatorStyle.None

        navigationItem.title = "Welcome!"

        self.tableView?.registerClass(UITableViewCell.self, forCellReuseIdentifier: "Cell")
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }

    override func numberOfSectionsInTableView(tableView: UITableView?) -> Int {
        return 1
    }

    override func tableView(tableView: UITableView?, numberOfRowsInSection section: Int) -> Int {
        return 1
    }

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

        cell.textLabel?.text = welcomeText
        cell.textLabel?.textColor = UIColor.whiteColor()
        cell.backgroundColor = UIColor.clearColor()

        cell.textLabel?.lineBreakMode = NSLineBreakMode.ByWordWrapping
        cell.textLabel?.numberOfLines = 0
        cell.textLabel?.sizeToFit()

        cell.userInteractionEnabled = false


        return cell
    }

    override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

        // Nothing should happen!

    }

    override func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
        let view = UIView()
        return view
    }

    let welcomeText: String = "In that pleasant district of merry England which is watered by the river Don, there extended in ancient times a large forest, covering the greater part of the beautiful hills and valleys which lie between Sheffield and the pleasant town of Doncaster. The remains of this extensive wood are still to be seen at the noble seats of Wentworth, of Warncliffe Park, and around Rotherham. Here haunted of yore the fabulous Dragon of Wantley; here were fought many of the most desperate battles during the Civil Wars of the Roses; and here also flourished in ancient times those bands of gallant outlaws, whose deeds have been rendered so popular in English song. Such being our chief scene, the date of our story refers to a period towards the end of the reign of Richard I., when his return from his long captivity had become an event rather wished than hoped for by his despairing subjects, who were in the meantime subjected to every species of subordinate oppression. The nobles, whose power had become exorbitant during the reign of Stephen, and whom the prudence of Henry the Second had scarce reduced to some degree of subjection to the crown, had now resumed their ancient license in its utmost extent; despising the feeble interference of the English Council of State, fortifying their castles, increasing the number of their dependants, reducing all around them to a state of vassalage, and striving by every means in their power, to place themselves each at the head of such forces as might enable him to make a figure in the national convulsions which appeared to be impending."

}

我在这里缺少什么?

0 个答案:

没有答案