title: ios swift show/hide an element in textView cell and clear its space
body: <p>I have a dynamic tableView. TableViewCell prototype looks like this:  </p>
  
  <p>"------------------"<br>
   label<br>
   segmentedControl  (yes | no)<br>
   textView<br>
  "------------------"  </p>
  
  <p>My question is how can i hide and then show textView that tableView can autoresize its cell height</p>
  
  <p>Here is my tableViewCell class:</p>
  
  <pre><code>class QuestionTableViewCell: UITableViewCell {
  
  @IBOutlet weak var question: UILabel!
  @IBOutlet weak var answer: UISegmentedControl!
  @IBOutlet weak var comment: UITextView! 
  </code></pre>
  
  <p>And here is my tableView cellForRowAtIndex:</p>
  
  <pre><code>func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt;   UITableViewCell {
      let cell = tableView.dequeueReusableCellWithIdentifier("QuestionCell", forIndexPath: indexPath) as! QuestionTableViewCell
  
      cell.question.text = "\(indexPath.row + 1). " + questions[indexPath.row]
      // check answer and set it to segmentedControl and set color
      if questionsAnswers[indexPath.row] == "YES" {
          cell.answer.selectedSegmentIndex = 0
          cell.answer.tintColor = UIColor(hex: 0x42DC5A)
      } else {
          cell.answer.selectedSegmentIndex = 1
          cell.answer.tintColor = UIColor(hex: 0xD9393E)
      }
  
      if cell.comment != nil {
          cell.comment.delegate = self
          cell.comment.text = "Add a note if necessary.."
          cell.comment.textColor = UIColor.lightGrayColor()
      }
  
      if questionsAnswers[indexPath.row] == "YES" {
          // here i have to hide cell.comment and its space
      } else {
          // here i have to show it if its possible
      }
  
      // pass indexPath.row to action
      cell.answer.tag = indexPath.row
      cell.answer.addTarget(self, action: "valueChanged:", forControlEvents: .ValueChanged)
  
      return cell
  }
  
  // fires when user taps on segmentedControl
  func valueChanged(sender: UISegmentedControl){
      // switch segment and update questionsAnswers array
      switch sender.selectedSegmentIndex {
      case 0:
          questionsAnswers[sender.tag] = "YES"
          sender.tintColor = UIColor(hex: 0x42DC5A)
      case 1:
          questionsAnswers[sender.tag] = "NO"
          sender.tintColor = UIColor(hex: 0xD9393E)
      default:
          break
      }
  }
  </code></pre>
  
  <p>questions - an array with text of question<br>
  questionsAnswers - an array when i save value from segmented control  </p>
  
  <p>Sorry if my question is bad, i'm newbie in ios programming(</p>