1
Example of ios table with partially hidden header http://i43.tinypic.com/2ihm39t.png帧并不受限于可见区域
在这里你可以看到,顶部头部分隐藏,它的大小与下一个相同的,但它的一部分被隐藏在表框后面。如果我将其大小设置为40,它将被完全隐藏。有人可以解释发生了什么吗?我已经将表格移动到不认为其边缘位于导航栏下方。桌子的样式很简单。
为表委托的代码:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{return 2;}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if(section == 0)
return 8;
if(section == 1)
return 16;
return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 50;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 70;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 70)] autorelease];
[view setBackgroundColor:[UIColor grayColor]];
return view;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"reuse"] autorelease];
cell.textLabel.text = [NSString stringWithFormat:@"%i", indexPath.row];
return cell;
}
我已经将此代码复制到新的沙箱项目,它的工作原理就像一个魅力!但是我不能在项目中达到同样的效果。 – trickster77777