cocoa touch - UITableViewHeaderFooterView in InterfaceBuilder -


i want create custom header section view in separate .xib using ib

however in ib cannot find component uitableviewheaderfooterview (similar uitableviewcell) , assign reuse it

so how create in custom header section?

i create class mysection inherits uitableviewheaderfooterview create .xib, mysection.xib register xib cell reuse

the problem is, how use initwitreuseidentifier....

it's absolutely possible , apple provides example here.

download sample code , @ sectionheaderview.xib.

the way create xib single uiview on it. then, set class type class inherits uitableviewheaderfooterview.

once have nib class inherits uitableviewheaderfooterview, call following register class reuse header or footer:

static nsstring * const sectionheaderviewidentifier = @"sectionheaderviewidentifier";  [self.tableview registernib:[uinib nibwithnibname:@"sectionheaderview" bundle:nil] forheaderfooterviewreuseidentifier:sectionheaderviewidentifier]; 

to put view use, implement table delegate method tableview:viewforheaderinsection: so:

- (uiview *)tableview:(uitableview *)tableview viewforheaderinsection:(nsinteger)section {      sectionheaderviewclass *sectionheaderview = (sectionheaderview *)[tableview dequeuereusableheaderfooterviewwithidentifier:sectionheaderviewidentifier];      // stuff...      return sectionheaderview; } 

Comments