diff --git a/SOMessaging/SOMessageInputView.m b/SOMessaging/SOMessageInputView.m index 57be49f..5523b9b 100644 --- a/SOMessaging/SOMessageInputView.m +++ b/SOMessaging/SOMessageInputView.m @@ -206,6 +206,9 @@ - (void)adjustTableViewWithCurve:(BOOL)withCurve scrollsToBottom:(BOOL)scrollToB UIEdgeInsets contentInsets = UIEdgeInsetsMake(self.tableView.contentInset.top, 0.0, keyboardFrame.size.height + self.frame.size.height, 0.0); NSInteger section = [self.tableView numberOfSections] - 1; + if (section==-1) { + return; + } NSInteger row = [self.tableView numberOfRowsInSection:section] - 1; NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section]; diff --git a/SOMessaging/SOMessagingViewController.m b/SOMessaging/SOMessagingViewController.m index 24de9a6..c088515 100644 --- a/SOMessaging/SOMessagingViewController.m +++ b/SOMessaging/SOMessagingViewController.m @@ -106,7 +106,9 @@ - (void)viewDidLayoutSubviews NSInteger section = self.conversation.count - 1; NSInteger row = [self.conversation[section] count] - 1; NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section]; - [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:NO]; + if ( indexPath.row !=-1) { + [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:NO]; + } } }); }