From 4019b5a38ccf8f9ceda9d940c74f013319573425 Mon Sep 17 00:00:00 2001 From: moathothman Date: Mon, 23 Jun 2014 16:40:00 +0300 Subject: [PATCH 1/2] fixes crash issue when there is no pre-loaded data . --- SOMessaging/SOMessageInputView.m | 3 +++ SOMessaging/SOMessagingViewController.m | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) 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..7033b58 100644 --- a/SOMessaging/SOMessagingViewController.m +++ b/SOMessaging/SOMessagingViewController.m @@ -106,7 +106,10 @@ - (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]; + NSLog(@" indexpath is %@ .. %li ,, %li ",indexPath, (long)indexPath.row,(long)indexPath.section); + if ( indexPath.row !=-1) { + [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:NO]; + } } }); } From f580f1d61d081c9e078e4c30ebda081fca39ded2 Mon Sep 17 00:00:00 2001 From: moathothman Date: Mon, 23 Jun 2014 16:41:07 +0300 Subject: [PATCH 2/2] cleaning up --- SOMessaging/SOMessagingViewController.m | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/SOMessaging/SOMessagingViewController.m b/SOMessaging/SOMessagingViewController.m index 7033b58..c088515 100644 --- a/SOMessaging/SOMessagingViewController.m +++ b/SOMessaging/SOMessagingViewController.m @@ -106,8 +106,7 @@ - (void)viewDidLayoutSubviews NSInteger section = self.conversation.count - 1; NSInteger row = [self.conversation[section] count] - 1; NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section]; - NSLog(@" indexpath is %@ .. %li ,, %li ",indexPath, (long)indexPath.row,(long)indexPath.section); - if ( indexPath.row !=-1) { + if ( indexPath.row !=-1) { [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:NO]; } }