2
我爲節標題和表標題創建自定義視圖UITableView
。的問題是,在截面圖(綠色)的出現在所述表頭視圖(紅色)UITableView節標題出現在表標題視圖
爲表頭視圖的代碼是
self.headerImageView = [[UIView alloc] init];
self.headerImageView.backgroundColor = [UIColor redColor];
self.tableView.tableHeaderView = self.headerImageView;
和我設置其幀這裏
- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
self.headerImageView.frame = CGRectMake(0, 0, CGRectGetWidth(self.tableView.frame), 100);
}
的代碼段標題
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *view = [[UIView alloc] init];
view.backgroundColor = [UIColor greenColor];
return view;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 40;
}
我在做什麼錯? 歡呼
是的,我終於明白,這個框架必須在'viewDidLoad'中設置。 – Jan 2015-02-09 13:14:36