iOS如何在UITableViewCell
中显示多个图像。 UITableViewCell
中的第一张图像应该是固定的(,即不应该从视图滚动)。ios如何在uitableviewcell中显示多个图像
-2
A
回答
1
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//static NSString *CellIdentifier = @"Cell";
NSString *CellIdentifier = [NSString stringWithFormat:@"S%1dR%1d",indexPath.section,indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
/// You need to create UIImageView and add it to cell.contentView such like
UIImageView *imgView1 = [UIImageview alloc] init];
imgeView1.fram = CGRectMake(@"AS U WANT") // set specific fram as u want.
[cell.contentView addSubview:imgView1];// add as it is.
.
.
.
Create it as you want and add as it is.
}
return cell;
}
0
下面是UITableView的
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if(cell==nil){
cell=[[[NSBundle mainBundle] loadNibNamed:@"CCell" owner:self options:nil] objectAtIndex:0];
UIButton *imgV1=(UIButton*)[cell viewWithTag:1];
UIButton *imgV2=(UIButton*)[cell viewWithTag:2];
UIButton *imgV3=(UIButton*)[cell viewWithTag:3];
[imgV1 addTarget:self action:@selector(btnTapped:) forControlEvents:UIControlEventTouchDown];
[imgV2 addTarget:self action:@selector(btnTapped:) forControlEvents:UIControlEventTouchDown];
[imgV3 addTarget:self action:@selector(btnTapped:) forControlEvents:UIControlEventTouchDown];
HJManagedImageV *img1=[[HJManagedImageV alloc] initWithFrame:CGRectMake(0, 0, imgV1.frame.size.width, imgV1.frame.size.height)];
HJManagedImageV *img2=[[HJManagedImageV alloc] initWithFrame:CGRectMake(0, 0, imgV2.frame.size.width, imgV2.frame.size.height)];
HJManagedImageV *img3=[[HJManagedImageV alloc] initWithFrame:CGRectMake(0, 0, imgV3.frame.size.width, imgV3.frame.size.height)];
img1.tag=img2.tag=img3.tag=10000;
img1.backgroundColor=img2.backgroundColor=img3.backgroundColor=[UIColor clearColor];
[imgV1 addSubview:img1];
[imgV2 addSubview:img2];
[imgV3 addSubview:img3];
}
int x=indexPath.row;
x=x*3;
UIButton *imgV1=(UIButton*)[cell viewWithTag:1];
UIButton *imgV2=(UIButton*)[cell viewWithTag:2];
UIButton *imgV3=(UIButton*)[cell viewWithTag:3];
HJManagedImageV *img1=(HJManagedImageV*)[imgV1 viewWithTag:10000];
HJManagedImageV *img2=(HJManagedImageV*)[imgV2 viewWithTag:10000];
HJManagedImageV *img3=(HJManagedImageV*)[imgV3 viewWithTag:10000];
[img1 clear];
[img2 clear];
[img3 clear];
[imgV1 setTitle:[self.tableArray objectAtIndex:x] forState:UIControlStateDisabled];
img1.url=[NSURL URLWithString:[self.tableArray objectAtIndex:x]];
[img1 showLoadingWheel];
[GlobalCacheManager manage:img1];
if((x+1) >= self.tableArray.count){
imgV2.hidden=imgV3.hidden=YES;
[imgV2 setBackgroundImage:nil forState:UIControlStateNormal];
[imgV3 setBackgroundImage:nil forState:UIControlStateNormal];
} else if((x+2)>=self.tableArray.count) {
img2.url=[NSURL URLWithString:[self.tableArray objectAtIndex:x+1]];
[img2 showLoadingWheel];
[GlobalCacheManager manage:img2];
imgV1.hidden=imgV2.hidden=YES;
imgV3.hidden=YES;
[imgV2 setTitle:[self.tableArray objectAtIndex:x+1] forState:UIControlStateDisabled];
[imgV3 setBackgroundImage:nil forState:UIControlStateNormal];
} else {
[img2 showLoadingWheel];
[img3 showLoadingWheel];
img2.url=[NSURL URLWithString:[self.tableArray objectAtIndex:x+1]];
[GlobalCacheManager manage:img2];
img3.url=[NSURL URLWithString:[self.tableArray objectAtIndex:x+2]];
[GlobalCacheManager manage:img3];
imgV2.hidden=imgV3.hidden=NO;
[imgV2 setTitle:[self.tableArray objectAtIndex:x+1] forState:UIControlStateDisabled];
[imgV3 setTitle:[self.tableArray objectAtIndex:x+2] forState:UIControlStateDisabled];
}
return cell;
}
你可以下载源代码的形式here主代码。
+0
对于由步骤更多的细节和步骤教程请在这里参考http://sugartin.info/2011/09/02/custom-table-view-which-contains-more-then-one-images/。 – 2013-03-22 06:40:57
相关问题
- 1. iOS:如何在imageview中dynamiclly显示多个图像?
- 2. 显示UITableViewCell中多个图像上传的进度指示器
- 3. 如何在另一个图像中显示多个图像。
- 4. 在IOS中显示图像
- 5. 在iOS中显示图像
- 6. UITableViewCell上的图像显示
- 7. iOS - UITableViewCell的图像在选择时会显示在桌面上?
- 8. 有条件地显示图像在UITableViewCell
- 9. 图像显示在URL从UITableviewCell
- 10. 如何显示多个图像?
- 11. 在UITableViewCell中显示突出显示的图像
- 12. 如何在UITableViewCell中添加一个或多个图像?
- 13. 在java中显示多个图像
- 14. 在tabbedpane中显示多个图像
- 15. 在PrettyPhoto中显示多个图像
- 16. iOS - 在UITableViewCell中显示菜单
- 17. 如何在iOS中的图中显示小图像
- 18. 为UITableViewCell创建图像缓存,但只显示一个图像
- 19. iOS - UiTableviewCell - 一次只在一个单元上显示背景图像
- 20. RecyclerView显示多个图像
- 21. 如何在一个tableview cell中显示多个图像ios?我得到的图像从符
- 22. 在图像视图中显示多个图像
- 23. 如何在图像视图中显示20个图像名称
- 24. 如何在WordPress中将多个图像显示为滑块?
- 25. 如何在JFrame中显示多个图像?
- 26. 如何在Unix命令行中显示多个图像?
- 27. 如何在pygame中显示多个图像?
- 28. 如何获取多个图像显示在Android的GridView中
- 29. 如何在行中显示多个上传的图像
- 30. 如何在ios中的uiscrollview中以gridview格式显示图像?
尝试使用customcell – 2013-03-22 06:33:10
http://www.appcoda.com/customize-table-view-cells-for-uitableview/ – BhushanVU 2013-03-22 06:34:57
是要显示像网格格式 – 2013-03-22 06:36:47