1

I have been struggling with what may be a bug in Xcode 6.0.1. I am building an app which has a similar scene as the apple compose section in the mail app. I am using

func textViewDidChange(textView: UITextView) {        

    self.tableView.beginUpdates()
    self.tableView.endUpdates()
}

which calls tableView.estimatedRowHeight and tableView.rowHeight = UITableViewAutomaticDimension in order to resize the cell accordingly using auto layout and simple constraints. I have cell.mytextview.delagete = self. This works flawlessly in my other scene where the text is is not entered by the user.

The problem is it appears that the cell caret/cursor is getting cut off when text reaches the keyboard or bottom of the screen. Also, if I press return repeatedly without entering text the caret/cursor disappears altogether for about 6 times until it scrolls me down to the bottom with the cursor still cut off. What I have realized is if I put 5 rows of text and then start back from rows enter text normally it works fine. Visually it looks similar to this. It just seems there is some gap where it is not auto scrolling to the correct place. I should also mention that the cell and textview are expanding because I can scroll down and see the text. I have already tried removing the other cells to see if they may have been causing the issue, but it had no effect. I have searched very hard on this and came up empty handed. Here is some relevant code.

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    var cellidentifier : String?


    if indexPath.row == 0 {

         cellidentifier = "tocell"

    }

    if indexPath.row == 1 {

         cellidentifier = "subjectcell"

    }

    if indexPath.row == 2 {

         cellidentifier = "bodycell"

    }



    let cell = tableView.dequeueReusableCellWithIdentifier(cellidentifier!) as composeTableViewCell

     if indexPath.row == 0 {

        cell.tofield!.text = toString
        cell.tofield?.delegate = self
     }

     if indexPath.row == 1 {

         cell.subjectfield?.delegate = self

     }

      if indexPath.row == 2 {

        cell.bodyfield?.delegate = self

      }

    return cell

}
Community
  • 1
  • 1
invertedfjord
  • 362
  • 1
  • 12
  • I have tried LOTs to solve that in a non buggy way - and there was no chance. It ended that i am now (its an iPad Application) present a Popover with a TextView and insert the created text then into my TableView. Otherwise i had similar problems like you. – derdida Oct 08 '14 at 21:41
  • The only way is to come up with some workaround. Only thing that comes to mind is to somehow make it think there is already some rows entered, but its hard to think of anything that is not too messy. – invertedfjord Oct 08 '14 at 23:06
  • kind of crazy that Apple has not made an easy way to accomplish this yet. I suppose I can disable auto layout altogether and programmatically insert everything. It seems kid of ridiculous to accomplish such an easy task. I have not found an easy way to do this on Xcode 6.3. Would be great to hear any ideas. – invertedfjord Apr 15 '15 at 20:32

1 Answers1

0

i hope this will use full until the Xcode fix the bug use enter code hereview.content = CGSizeMake(0,800) //like this and implement as per orientation

NRV
  • 57
  • 1
  • I used func textViewDidChange(textView: UITextView) { textView.contentSize = CGSizeMake(0, 800). this did not seem to have any effect. Is there anywhere else I can put this to fix or am I missing something? – invertedfjord Dec 17 '14 at 18:39