iphone - Add Image and Caption Text to Three20 Table section using TTSectionedDataSource -
i trying create table using tttableviewcontroller
. want display image in section header along caption text, similar instagram , many other application does. tried using sample ttnavigatordemo
display data ttsectioneddatasource
, (i not sure if right way it, please suggest better way if know any). contains section name/headers regular strings , data tttableviewitem
. tried implementing <uitableviewdelegate>
protocol , achieved using viewforheaderinsection
method, data separated section, there better way using three20 through can pass on header/section view , tableitemview
along in datasource allow me implement tttableviewdragrefreshdelegate
, not able implement when implementing <uitableviewdelegate>
protocol in class.
my class declaration right now, looks like
@interface imagetable : tttableviewcontroller <uitableviewdelegate> { }
i show section headers image , text like:
:
i using ttnavigatorcode
populate data in table is:
self.datasource = [ttsectioneddatasource datasourcewithobjects: @"food" [tttableviewitem itemwithtext:@"porridge" url:@"tt://food/porridge"], [tttabletextitem itemwithtext:@"bacon & eggs" url:@"tt://food/baconeggs"], [tttabletextitem itemwithtext:@"french toast" url:@"tt://food/frenchtoast"], @"drinks", [tttabletextitem itemwithtext:@"coffee" url:@"tt://food/coffee"], [tttabletextitem itemwithtext:@"orange juice" url:@"tt://food/oj"], @"other", [tttabletextitem itemwithtext:@"just desserts" url:@"tt://menu/4"], [tttabletextitem itemwithtext:@"complaints" url:@"tt://about/complaints"], @"other", [tttabletextitem itemwithtext:@"just desserts" url:@"tt://menu/4"], [tttabletextitem itemwithtext:@"complaints" url:@"tt://about/complaints"], nil];
i able make similar implementing method:
- (uiview *)tableview:(uitableview *)tableview viewforheaderinsection:(nsinteger)section { return mycustomview; }
but since data coming model class , want generate views , add them datasource in formatted way. know if there way using three20 through specify array of data sections , array corresponding data under sections?
your highly appreciated
thanks
create delegate footabledelegate.h
@interface footabledelegate : tttableviewdragrefreshdelegate { } - (uiview*) createheaderview:(foodatasource *)fdatasource forsectionid:(nsstring *)secid; @end
in footabledelegate.m file
- (uiview*)tableview:(uitableview *)tableview viewforheaderinsection:(nsinteger)section { if (tableview.style == uitableviewstyleplain) { if ([tableview.datasource respondstoselector:@selector(tableview:titleforheaderinsection:)]) { nsstring* title = [tableview.datasource tableview:tableview titleforheaderinsection:section]; if (title.length > 0) { uiview* header = [_headers objectforkey:title]; if (nil != header) { header.alpha = 1; } else { if (nil == _headers) { _headers = [[nsmutabledictionary alloc] init]; } header = [self createheaderview:tableview.datasource forsectionid:title]; [_headers setobject:header forkey:title]; } return header; } } } return nil; } - (uiview*) createheaderview:(feeddatasource *)fdatasource forsectionid:(nsstring *)secid { //do code header view return view; } - (cgfloat)tableview:(uitableview *)tableview heightforheaderinsection:(nsinteger)section { //return height section header return height; }
this solve problem
Comments
Post a Comment