【发布时间】:2013-10-03 04:23:00
【问题描述】:
上下文
- 为 iOS 7 构建
- 视图控制器上有两个 UITableView
- 使用约束使 tableview 调整大小,就像我想要的那样,在 3.5 英寸和 4 英寸的屏幕尺寸之间。
我的尝试
- 阅读 UITableView 文档
- 搜索stackoverflow
- 试过这个代码:
[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 {
}
【问题讨论】:
-
你能用单元格和你的tableview代码显示实际图像吗?
-
拜托,你能在你提供 tableView (框架,代表......)的地方显示代码吗?谢谢?
-
我没有看到您提供的代码有问题,但我没有看到您如何在代码或界面构建器中设置表格视图。我也看不到运行时发生了什么。介意压缩项目并分享它,以便我们仔细查看吗?
-
@HelgeBecker 给你:dl.dropboxusercontent.com/u/529504/Example.zip
标签: iphone ios objective-c uitableview