Iphone iOS:具有3个字段的自定义UITableViewCell
我想创建一个带有3个字段的自定义UITableViewCell。我希望每个字段都可以水平滚动 Field1 Field2 Field3 ====== ====== ====== Label1 | Label2 | [graphics: lines, etc.] 字段1字段2字段3 ====== ====== ====== Label1 | Label2 |[图形:线条等] 我的问题是:实现这一点的正确方式是什么Iphone iOS:具有3个字段的自定义UITableViewCell,iphone,ios5,Iphone,Ios5,我想创建一个带有3个字段的自定义UITableViewCell。我希望每个字段都可以水平滚动 Field1 Field2 Field3 ====== ====== ====== Label1 | Label2 | [graphics: lines, etc.] 字段1字段2字段3 ====== ====== ====== Label1 | Label2 |[图形:线条等] 我的问题是:实现这一点的正确方式是什么 是否创建具有3个UITableView的自定
谢谢大家! 我将创建一个单独的
UITableView
,其中包含uiscrollview
、UIlabel
和UIImageView的UITableView单元格
,您可能需要使用其他选项,使用一个带有单个UITableView
的UIViewController
一个自定义的带有三个UIScrollView的UITableViewCell将对您有所帮助。nilweed先生。在这里,它将帮助您在UITableView单元格中添加三个字段。我不知道如何水平滚动tableview
-(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;
}
我希望这会对你有所帮助
谢谢。在其中创建自己的自定义TableViewCell,首先将UiScrollView放入其中。在2个Uilabel和1个UiView中(根据您的问题),通过intefacebuilder关闭uiscrollView的垂直滚动。设置uiscrollView的contentSize属性。确保uiscrollView的contentSize宽度大于单元格宽度