public override void DidCommitTextEditing (NSObject sender) { // Notifies the view controller when tapped on the right "Accept" button for commiting the edited text var message = new Message { Username = CurrentUsername, Text = TextView.Text, ProfileColor = CurrentProfileColor }; messages.RemoveAt (0); messages.Insert (0, message); TableView.ReloadData (); base.DidCommitTextEditing (sender); }
public override void DidPressRightButton (NSObject sender) { // Notifies the view controller when the right button's action has been triggered, manually or by using the keyboard return key. // This little trick validates any pending auto-correction or auto-spelling just after hitting the 'Send' button TextView.RefreshFirstResponder (); var message = new Message { Username = CurrentUsername, Text = TextView.Text, ProfileColor = CurrentProfileColor }; var indexPath = NSIndexPath.FromRowSection (0, 0); var rowAnimation = Inverted ? UITableViewRowAnimation.Bottom : UITableViewRowAnimation.Top; var scrollPosition = Inverted ? UITableViewScrollPosition.Bottom : UITableViewScrollPosition.Top; TableView.BeginUpdates (); messages.Insert (0, message); TableView.InsertRows (new []{ indexPath }, rowAnimation); TableView.EndUpdates (); TableView.ScrollToRow (indexPath, scrollPosition, true); // Fixes the cell from blinking (because of the transform, when using translucent cells) // See https://github.com/slackhq/SlackTextViewController/issues/94#issuecomment-69929927 TableView.ReloadRows (new []{ indexPath }, UITableViewRowAnimation.Automatic); base.DidPressRightButton (sender); }