Reputation: 183
I would like to create a custom UITableViewCell with 3 fields. I would like each of the fields to be horizontally scrollable.
Field1 Field2 Field3 ====== ====== ====== Label1 | Label2 | [graphics: lines, etc.]
My question: What is the right way to implement this?
Any examples would be great.
Thank you!
Upvotes: 0
Views: 269
Reputation: 3020
Create your own custom TableViewCell inside that firstly put UiScrollView. inside that 2 Uilabel and 1 UiView i think(acoording to your question).off the vertical scrolling of uiscrollView through intefacebuilder. set the contentSize property of uiscrollView.be sure your widhth of ContentSize of UiScrollView greater than your cell width.
Upvotes: 1
Reputation: 9801
Mr. nilweed. Here it will help you to add three fields in UITableView cells. I don't know to scroll the tableview horizontally.
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier=@"CellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier: CellIdentifier] autorelease];
NSString *cellIconName = [[self cellIcon] objectAtIndex:[indexPath row]];
cellImage=[UIImage imageNamed:cellIconName];
cell.imageView.image=cellImage;
UILabel *labelOne = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 60, 20)];
labelOne.tag = 100;
[cell.contentView addSubview:labelOne];
[labelOne release];
UILabel *labelTwo = [[UILabel alloc]initWithFrame:CGRectMake(80, 10, 60, 20)];
labelTwo.tag = 101;
[cell.contentView addSubview:labelTwo];
[labelTwo release];
UILabel *labelThree = [[UILabel alloc]initWithFrame:CGRectMake(160, 10, 150, 20)];
labelTwo.tag = 103;
[cell.contentView addSubview:labelTwo];
[labelTwo release];
}
UILabel *labelOne = (UILabel *) [cell.contentView viewWithTag:100];
labelOne.text = @"Label One";
UILabel *labelTwo = (UILabel *) [cell.contentView viewWithTag:101];
labelTwo.text = @"Label Two";
UILabel * labelThree = (UILabel *) [cell.contentView viewWithTag:101];
labelThree.text = @"Label Three";
return cell;
}
I hope it will help you a little bit.
Thanks.
Upvotes: 0
Reputation: 17478
You might need to go with Other option, with a single UIViewController
with a single UITableView
.
A Custom UITableViewCell
with three UIScrollView
s would help you.
Upvotes: 0
Reputation: 4546
I would create a single UITableView
with dequeued UITableViewCell
's that contains UIScrollViews
, UIlabel
and UIImageView
's
Upvotes: 0