我想改变tableHeader高度,字体等......
我实施UITableViewDelegate,UITableViewDataSource并添加heightForHeaderInSection和viewForHeaderInSection.但是这两种方法都没有被调用.其他方法如numberOfRowsInSection/ cellForRowAtIndexPath正在正常工作.我可以看到表但没有标题:(
任何的想法?
这是代码:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.poHeader.itemList count];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
NSLog(@"numberOfSectionsInTableView");
return 1;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
NSLog(@"*******height");
return 44.0;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
NSLog(@"***in viewForHeader In section");
UIView* customView = [[UIView alloc] initWithFrame:CGRectMake(2, 166, 300.0, 44.0)];
UILabel * headerLabel = [[UILabel alloc] initWithFrame:CGRectZero];
headerLabel.backgroundColor = [UIColor clearColor];
headerLabel.opaque = NO;
headerLabel.textColor = [UIColor blackColor];
headerLabel.highlightedTextColor = [UIColor whiteColor];
headerLabel.font = [UIFont systemFontOfSize:13];
headerLabel.frame = CGRectMake(2, 166, 300.0, 44.0);
headerLabel.text = @"Part No. Description Ext Cost"; // i.e. array element
[customView addSubview:headerLabel];
return customView;
}
Run Code Online (Sandbox Code Playgroud)
Kla*_*aas 17
差不多一年之后,但我想你只设置了数据源而不是代理人?
你必须在你的控制器中有这样的东西:
myTableview.delegate = self;
myTableview.dataSource = self;
Run Code Online (Sandbox Code Playgroud)
您提到调用了numberOfRowsInSection/cellForRowAtIndexPath.两者都属于UITableViewDataSource而不属于UITableViewDelegate.
| 归档时间: |
|
| 查看次数: |
5423 次 |
| 最近记录: |