I have read https://stackoverflow.com/questions/
and tried as this:
//UITableView
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.rowHeight = UITableViewAutomaticDimension;
self.tableView.estimatedRowHeight = 50;
//Update the full code for the "return" key action
- (void)inputViewDidTapReturn:(MyInputView *)inputView text:(NSString *)text{
NSLog(@"send text-----%@",text);
[self.messageManager sendMessageTo:self.sessionID message:text completion:^(BOOL success, Message *message) {
if (success) {
[self.dataArray addObject:message];
NSIndexPath * bottomIndexPath = [NSIndexPath indexPathForRow:self.dataArray.count-1 inSection:0];
[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:@[bottomIndexPath] withRowAnimation:UITableViewRowAnimationLeft];
[self.tableView endUpdates];
[self.tableView scrollToRowAtIndexPath:bottomIndexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
} else {
}
}];
}
But the result did not show correctly:
It started scroll from the bottom of the screen.
The UITableView
and UITableViewCell
are both used Auto Layout and the UITableView
is on top of the keyboard already.
Any help will be greatly appreciated.