是否可以加载高度为672的视图作为TableView标题?我添加了它,但我无法滚动和查看表格视图单元格的详细信息。我已经用过代码了
ACCRemainderView *header = [ACCRemainderView customHeaderView];
[self.tableView setTableHeaderView:header];在剩余部分视图中
+ (id)customHeaderView
{
ACCRemainderView *customView = [[[NSBundle mainBundle] loadNibNamed:@"ACCRemainderView" owner:nil options:
nil] lastObject];
//make sure customView is not nil or the wrong class!
if ([customView isKindOfClass:[ACCRemainderView class]]) {
return customView;
} else {
return nil;
}
}发布于 2014-04-25 21:23:19
尝试在UITableViewController中实现- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section并返回[ACCRemainderView customHeaderView]。
发布于 2014-04-25 21:33:07
设置tableHeaderView是最好的选择。我测试过了,它工作正常。
ViewForHeaderInSection不能,因为此视图头的高度大于表的高度。
你不能滚动,我想你的tableView被另一个视图重叠了。
- (void)viewDidLoad
{
[super viewDidLoad];
_tableView.dataSource = self;
_tableView.delegate = self;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
NSString *title=[self tableView:tableView titleForHeaderInSection:section];
if ( !title )
return nil;
UIView *view = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 500)];
view.backgroundColor = [UIColor greenColor];
return view;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 500;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 2;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return @"abcd";
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 50;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = (UITableViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = @"a";
return cell;
}https://stackoverflow.com/questions/23294012
复制相似问题