IOS App Fix TableView To Bottom Like Messages

So, this is completely out of my field (expertise?), So I decided that I would ask him and see if someone more experienced could give me the answer β€œyes” or β€œno”.

So, I use Appcelerator Titanium to create an application with a lot of table views. I want to build it so that some of the tableViews start at the bottom, and I can scroll UP instead of DOWN to start, just like the Messages app on iPhone.

The way it works is loading content, and it is automatically loaded using a table fixed at the bottom, then you can scroll up to see old messages.

I cannot find a way to do this in the appcelerator, other than creating a table, loading data, and then scrolling it to the bottom (which obviously has this binding). I can hide the table view, scroll down and then show the tableview, but again ... not perfect.

Now the question is ... Is it possible to use the standard iOS SDK (Not appcelerator) to set the table for correction at the bottom, and not the top? If not, I will somehow find a job. If so, I would try to build it into a titanium module, if at all possible ...

Anyway, thanks! And hopefully this is a simple answer for some of you.

+4
source share
2 answers

Actually, this is really pretty trivial. Something like this will work just fine:

-(void)viewDidLoad { //place this at the bottom of your viewDidLoad method, or in any method that initially reloads the table NSIndexPath* ipath = [NSIndexPath indexPathForRow: myArray.count-1 inSection: 0]; [tableView scrollToRowAtIndexPath: ipath atScrollPosition: UITableViewScrollPositionBottom animated: NO] } 
+9
source

I tried scrolling in viewDidLoad, but after the view controller appears, I see how the beginning of the table appears in the view.

I found a better place to start scrolling.

 - (void) viewDidLayoutSubviews { [super viewDidLayoutSubviews]; NSInteger lastSectionIndex = MAX(0, [self.chatTableView numberOfSections] - 1); NSInteger lastRowIndex = MAX(0, [self.chatTableView numberOfRowsInSection:lastSectionIndex] - 1); NSIndexPath *lastIndexPath = [NSIndexPath indexPathForRow:lastRowIndex inSection:lastSectionIndex]; [self.chatTableView scrollToRowAtIndexPath:lastIndexPath atScrollPosition:UITableViewScrollPositionBottom animated:NO]; } 
0
source

All Articles