環境
- iOS 7 向けのビルド
- ビューコントローラー上の 2 つの UITableView
- 制約を使用して、テーブルビューを 3.5 インチから 4 インチの画面サイズに合わせてサイズ変更します。
私が試したこと
- UITableView のドキュメントを読む
- 検索スタックオーバーフロー
- このコードを試しました:
[self.bottomTableView scrollToRowAtIndexPath:0 atScrollPosition:UITableViewScrollPositionTop animated:NO];
結果
- 下部の tableView のコンテンツは、tableview の中央に読み込まれます。これらのセルをテーブル ビューの上部に向かってスクロールできますが、中央に「スナップ」されます。どうすればこれを回避できますか?
アップデート
これは、ロード時にテーブルビューがどのように見えるかです。緑色の背景は、下部のテーブル ビューの上半分に残されたすべての空白を示しています。
これはコードです:
#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 {
}