0
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cellFrame = CGRectMake(0, 0, tableView.frame.width, 100)
var retCell = UITableViewCell(frame: cellFrame)
 var textView = UITextView(frame: CGRectMake(8,30,tableView.frame.width-8-8,65))
            textView.layer.borderColor = UIColor.blueColor().CGColor
            textView.layer.borderWidth = 1
                                retCell.addSubview(textView)
                                if(reqGrpIndex == 0){
                reqGrpIndex = reqGrpIndex + 1
            }
}

Why shouldn't we add subview on this function?? How can change the code to be a good practice for doing same purpose?

Mestica
  • 1,489
  • 4
  • 23
  • 33
henry
  • 83
  • 1
  • 13

1 Answers1

0

You are using this function in a wrong way.This function is used to initiate tableView cell and load data to that initiated table view cell.And also it's a good practice to reusable cells and load related information to that cell. By the way this question has really good accepted answer and this answer will help you to understand tableView concept well.And also there is nice tutorial which explain about tableView

Community
  • 1
  • 1
Mudith Chathuranga Silva
  • 7,253
  • 2
  • 50
  • 58