如何在willDisplayCell方法中配置UITableViewCell?

war*_*_fz 0 objective-c uitableview custom-cell ios

我正在尝试初始设置UITableViewCellin将显示单元格,但它不起作用.谁能帮我吗?

-(void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *) cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
     cell.awtxt.font = [UIFont fontWithName:@"Helvetica" size:15.0]; //i am unable to set this .awtxt is the property outlet in my custom ui table view cell named as "postCell"
}
Run Code Online (Sandbox Code Playgroud)

Mik*_*lty 5

对我来说,当我将方法更改为UITableViewCell自定义单元格时,它可以正常工作.所以只需UITableViewCell用你的自定义替换postCell

 -(void) tableView:(UITableView *)tableView willDisplayCell:(postTableViewCell *) cell forRowAtIndexPath:(NSIndexPath *)indexPath // replace "postTableViewCell" with your cell
 {

  cell.awtxt.font = [UIFont fontWithName:@"Helvetica" size:15.0]; //i am unable to set this .awtxt is the property outlet in my custom ui table view cell named as "postCell"

 }
Run Code Online (Sandbox Code Playgroud)

  • 好的,当你有多个自定义原型单元时会发生什么?你如何迎合他们所有的willDisplayCell方法? (6认同)