Using a XIB file for custom Tableview Section Header

后端 未结 3 1977
余生分开走
余生分开走 2021-02-15 15:33

I wanted to use a xib file to customise a tableview section in xcode (objective C), and here ar my files:

SectionHeaderView.xib is a UIView with a UILabel

Sectio

3条回答
  •  Happy的楠姐
    2021-02-15 15:48

    Try this: I have tested it in my app and its working:

    NSArray *viewArray =  [[NSBundle mainBundle] loadNibNamed:@"SectionHeaderview" owner:self options:nil];  
    UIView *view = [viewArray objectAtIndex:0]; 
    UILabel *lblTitle = [view viewWithTag:101]; 
    lblTitle.text = @"Text you want to set"; 
    return view;
    

提交回复
热议问题