خرید بک لینک

Vote count: 0

I wrote a UITableView that has custom UITableViewCell, and the data loading and the table data population has no problem, but the Cell height is so wrong that the content of each cell is only half visible (see the attached screenshots)

tableview cell xib

I have a .xib file (as show in the second screenshot above) for the UITableViewCell and have written a class that overrides the UITableViewCell class with the layoutSubviews() implementation below, in which I used the [Neon][3] library to do the positioning/layout of the UI elements:

override func layoutSubviews() {
        super.layoutSubviews()
        self.contentView.clipsToBounds = true


        avatarImage.anchorInCoer(.TopLeft, xPad: 2, yPad: 2, width: 15, height: 15)
        postedByUseame.align(.ToTheRightCentered, relativeTo: avatarImage, padding: 1, width: 190, height: 15)

        timeAgo.anchorInCoer(.TopRight, xPad: 2, yPad: 2, width: 130, height: 15)

        questionTitle.alignAndFill(align: .UnderMatchingLeft, relativeTo: avatarImage, padding: 3)
        firstAttachedImage.align(.ToTheRightMatchingTop, relativeTo: questionTitle, padding: 3, width: 40, height: 40)

        self.answerButton.setFAText(prefixText: "", icon: FAType.FAReply, postfixText: "2", size: 14, forState: .Normal)
        self.commentButton.setFAText(prefixText: "", icon: FAType.FACommentO, postfixText: "1", size: 14, forState: .Normal)
        self.likeButton.setFAText(prefixText: "", icon: FAType.FAHeartO, postfixText: "10", size: 14, forState: .Normal)

        answerCommentLikeStackView.align(.UnderMatchingLeft, relativeTo: questionTitle, padding: 3, width: 190, height: 30)

        self.setNeedsUpdateConstraints()        
    }

In my UITableViewController implementation, I set the cell/row height like below:

 self.tableView.rowHeight = UITableViewAutomaticDimension
        self.tableView.estimatedRowHeight = 150
        self.tableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0)
        self.tableView.separatorStyle = UITableViewCellSeparatorStyle.SingleLine

        // disable horizontal scroll
        self.tableView.contentSize = CGSizeMake(self.tableView.frame.size.width, self.tableView.contentSize.height)

But the cell height is still wrong, what else can I do to make the height look right?

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 8 ارديبهشت 1395 ساعت: 7:46

صفحه بندی