Context
- Building for iOS 7
- Two UITableViews on a viewcontroller
- Using constraints so tableview resize like I'd like for between 3.5inch and 4inch screen sizes.
What I've tried
- Read UITableView documentation
- Search stackoverflow
- tried this code:
[self.bottomTableView scrollToRowAtIndexPath:0 atScrollPosition:UITableViewScrollPositionTop animated:NO];
Result
- The content in the bottom tableView loads in the middle of the tableview. I can scroll those cells upwards towards the top of the table view, but they "snap" back to the middle. How do I avoid this?
Update
This is how the tableview looks on load. The green background shows all the white space that left on the top half of the bottom table view.
This is the code:
#pragma mark - Table View Methods
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (tableView == self.topTableView) {
return [self.array count];
}
else{
return [self.array count];
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"SimpleTableItem";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
if (tableView == self.topTableView) {
cell.textLabel.text = @"60";
return cell;
}
else{
cell.textLabel.text = @"60";
return cell;
}
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
}