objective c - Unable to add header and footer for a table view controller -
@property(nonatomic,retain) uiview *tableheaderview; // accessory view above row content. default nil. not confused section header @property(nonatomic,retain) uiview *tablefooterview; // accessory view below content. default nil. not confused section footer
i have added label in footer view inner coding according requirements no need make global variables.
- (uiview *)tableview:(uitableview *)tbleview viewforfooterinsection:(nsinteger)section { uilabel *label; label = [[[uilabel alloc] initwithframe:cgrectmake(10, 0, 300, 30)]autorelease]; [label setbackgroundcolor:[uicolor clearcolor]]; label.textalignment = uitextalignmentcenter; [label settextcolor:[uicolor whitecolor]]; [label setfont:[uifont boldsystemfontofsize:15.0]]; [label settext:nslocalizedstring(@"instructions personal profile",@"instructions personal profile")]; uiview *view = [[[uiview alloc] initwithframe:cgrectmake(0, 0, 320, 30)]autorelease]; [view setautoresizingmask:uiviewautoresizingflexiblewidth]; [view addsubview:label]; return view; } - (uiview *)tableview:(uitableview *)tableview viewforheaderinsection:(nsinteger)section }
for setting height of footer , header use:-
- (cgfloat)tableview:(uitableview *)tableview heightforheaderinsection:(nsinteger)section { } - (cgfloat)tableview:(uitableview *)tableview heightforfooterinsection:(nsinteger)section { }
Comments
Post a Comment