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
}