My current class declaration looks like
@ interface ImageTable: TTTableViewController{}
I want to display section titles with images and text, such as:
:
I am currently using TTNavigatorCode to Fill my data
The 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];
By implementing this method, I can do something similar:
- (UIView *)tableView:(UI TableView *)tableView viewForHeaderInSection:(NSInteger)section {
return myCustomView;
}
But since my data comes from model classes, I want to generate views and format them Add to the data source. I want to know if there is a way to use Three20, through which I specify my data array for the sections and another array for the corresponding data under these sections?
Thank you very much for your help
Thank you
@interface FOOTableDelegate: TTTableViewDragRefreshDelegate
{
}
- (UIView*) createHeaderView:(FOODataSource *)fDataSource forSectionID:(NSString *)secID;
@end
In the FOOTableDelegate.m file
< /p>
- (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 some code for header View
return View;< br />
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
//re turn height for the Section Header
return height;
}
This will help you solve the problem
I am trying to use TTTableViewController creates the table. I want to display an image in the section header along with some header text, similar to what instagram and many other apps do. I try to use the example in TTNavigatorDemo to display the data from TTSectionedDatasource, (I’m not sure if this Is the right way, if you know, please suggest some better way). It contains section name/title as regular string, data contains TTTableViewItem. I tried to implement
My current class declaration looks like
@interface ImageTable: TTTableViewController{}
I want to display section titles with images and text, such as:
:
I am currently using TTNavigatorCode to fill in my data.
The table is:
< p>
self.dataSource = [TTSectionedDataSource dataSourceWithObjects:
@"Food"
[TTTableViewItem itemWithText:@"Porridge" URL:@"tt://food/porridge"] ,
[TTTableTextI tem 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];
By implementing this method, I can do something similar:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
return myCustomView;
}
But since my data comes from the model class, I want to generate views and add them to the data source in a formatted manner. I want to know if there is a way to use Three20 Method, through which I specified my data array for the sections and another array for the corresponding data under these sections?
Thank you very much for your help
Thank you
Create delegate FOOTableDelegate.h
@interface FOOTableDelegate: TTTableViewDragRefreshDelegate
{
}
- (UIView*) createHeaderView:(FOODataSource *)fDataSource forSectionID :(NSString *)secID;
@end
In the 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)
{< br /> 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 some code for header View
return View;
)
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
//return height for the Section Header
return height ;
}
This will help you solve the problem