我觉得你可以去这里创业
How to display the UITableView programmatically?
好吧,如果您知道如何加载 uitableview,我认为您可以开始使用复杂的部分。
你需要在你的 cellForRow 方法中添加这行代码
您需要根据您的要求设置帧大小和图像名称
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if(cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:cellIdentifier];
}
if(indexPath.row == 0)
{
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(14, 14, 15, 15)];
imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"image1.png", ]];
[cell.contentView addSubview:imageView];
[imageView release];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(14, 14, 15, 15)];
imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"image2.png", ]];
[cell.contentView addSubview:imageView];
[imageView release];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(14, 14, 15, 15)];
imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"image3.png", ]];
[cell.contentView addSubview:imageView];
[imageView release];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(14, 14, 15, 15)];
imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"image4.png", ]];
[cell.contentView addSubview:imageView];
[imageView release];
}
else if(indexPath.row == 1)
{
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(14, 14, 15, 15)];
imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"image5.png", ]];
[cell.contentView addSubview:imageView];
[imageView release];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(14, 14, 15, 15)];
imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"image6.png", ]];
[cell.contentView addSubview:imageView];
[imageView release];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(14, 14, 15, 15)];
imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"image7.png", ]];
[cell.contentView addSubview:imageView];
[imageView release];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(14, 14, 15, 15)];
imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"image8.png", ]];
[cell.contentView addSubview:imageView];
[imageView release];
}
else if(indexPath.row == 2)
{
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(14, 14, 15, 15)];
imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"image9.png", ]];
[cell.contentView addSubview:imageView];
[imageView release];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(14, 14, 15, 15)];
imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"image10.png", ]];
[cell.contentView addSubview:imageView];
[imageView release];
}
else
{
// Do something here
}
return cell;
}
编辑:
@Christy 你可以有一个可以让表格视图滚动的按钮。但是iphone用户习惯看表格右边的滚动条,看表格是否还有数据。
但是如果你想要一个滚动表格的按钮,那么这里就是代码
在此块 else if(indexPath.row == 2){} 的 tableView 的 cellForRow 方法中添加一个带有向下箭头的 UIButton
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(220.0f, 5.0f, 150.0f, 38.0f)];
[button setImage:[UIImage imageNamed:@"Arrow"] forState:UIControlStateNormal];
[button addTarget:self action:@selector(doSomething) forControlEvents:UIControlEventTouchUpInside];
[cell addSubview:button];
[button release];
在选择器方法中
- (void)doSomething
{
[tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:3 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES]
}