Reputation: 28905
How can I make a UITableViewCell with three columns in this format:
|Text=======xxx===yy%|
where "|" represents the end of the cells and "=" is spacing. "Text" is any text, "xxx" is some integer, and "yy%" is some percent.
Right now, I have this format:
|Text==============xxx| using this code in my cellForRowAtIndexPath: method:
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [theTableView dequeueReusableCellWithIdentifier:CellIdentifier];
BOOL inthere = NO;
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.textLabel.font = [UIFont systemFontOfSize:12];
cell.detailTextLabel.font = [UIFont systemFontOfSize:12];
and then later in that method:
cell.detailTextLabel.text = str2;
cell.textLabel.text = str1;
But I'd like to add another column towards the end. Does anyone know how to achieve this "three column" sort of style?
Upvotes: 2
Views: 1389
Reputation: 52227
There are quite a few ways to have a custom cell.
Have a look at Apple's TableView Programming Guide for an overview.
Most likely subclassing is your way to go.
TableViewSuite is a sample code project, that shows the different ways to create custom cells.
Upvotes: 1
Reputation: 46
you can override UITableViewCell
and write your own customize cell.
here is a tutorial : http://blog.webscale.co.in/?p=284 for implementing custem cell;
instead of using their custom cell class go to xcode and make new file, choose objective-C class and in the drop box choose subclass of uitableviewcell, that will give you nice template to work with.
Upvotes: 2
Reputation: 25632
Subclass UITableViewCell
to build your custom cells and use those. Either add three UILabel
s (more convenient) to it or draw everything yourself in drawRect:
(faster).
Upvotes: 4