我正在使用表格视图(列表视图)那里我正在单元格中显示图像,图像显示但不是相同大小的所有不同大小。我希望所有相同高度和宽度的图像。 任何人都可以给我这个代码。 TNX ..显示表格的单元格中相同宽度和高度的图像
回答
这样做,
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell=nil;
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
CGRect imageFrame = CGRectMake(2, 8, 40, 40);
UIImage *img = [[[UIImage alloc] initWithData:data] autorelease];
UIImageView *customImage = [[[UIImageView alloc] initWithFrame:imageFrame] autorelease];
customImage.image=img;
[cell.contentView addSubview:customImage];
}
return cell;
}
只是cellForRowAtIndexPath:
方法类似波纹管与帧添加图像.. 你也可以使用UIImageView
代替AsynchImageView
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"ImageCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]
initWithFrame:CGRectZero reuseIdentifier:CellIdentifier]
autorelease];
} else {
AsyncImageView* oldImage = (AsyncImageView*)
[cell.contentView viewWithTag:999];
[oldImage removeFromSuperview];
}
CGRect frame;
frame.size.width=75; frame.size.height=75;
frame.origin.x=0; frame.origin.y=0;
AsyncImageView* asyncImage = [[[AsyncImageView alloc]
initWithFrame:frame] autorelease];
asyncImage.tag = 999;
NSURL* url = [imageDownload
thumbnailURLAtIndex:indexPath.row];
[asyncImage loadImageFromURL:url];
[cell.contentView addSubview:asyncImage];
return cell;
}
也See This Demo您的需求
我希望这会帮助你...
感谢很多旁遮普.. – Ninja
@deepak第一次尝试演示,我发布这里的链接波纹管或从这里也看到tableview与整个图像队友http://www.markj.net/iphone-asynchronous-table-image/ ... –
我从另一个URL获取userid我将该userId保存在一个变量(USERID)我试过http ://abc.com/user/USERID/bookmarksdata 和http://abc.com/user/"+USERID+"/bookmarksdata,but not can take user id。 – Ninja
在数据源的tableview方法-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
用于图像视图 cell.imageView.frame
非常感谢.. – Ninja
- 1. PPM图像格式,高度和宽度不显示 - C
- 2. Firefox,CSS显示:表格/表格单元格和高度
- 3. 基金会4表格单元格中的图像不显示在定义的宽度高度
- 4. 集合视图单元格中的高度和宽度
- 5. 固定宽度表格 - 宽度不同的单元格?
- 6. 如何显示:表格单元格与我的CSS具有相同的高度?
- 7. HTML CSS两个相同高度和宽度的2列表格
- 8. 表格:行中单元格的高度相同
- 9. 表格单元正好是高度的50%和宽度的50%
- 10. 拉伸TextView宽度和高度等于GridLayout的单元格宽度高度
- 11. 表格单元格高度显示不同IE8 vs IE7 vs Firefox
- 12. HTML/CSS:跨行的表格单元格宽度相同
- 13. 在不同行中显示不同单元格宽度的表格
- 14. 表格单元格高度
- 15. 图片的高度,宽度和格式
- 16. 单元格高度等于图像宽度
- 17. 将电子表格中的所有单元格设置为相同的指定高度和宽度
- 18. 使表格单元的大小相同(宽度/高度)不计算标题
- 19. 如何让表格单元格具有相同的高度
- 20. 具有显示的div的高度:表格单元格
- 21. 最小高度和表格单元格
- 22. 用于列的CSS“显示:表格单元格” - 使第一列的宽度与最宽的单词相同
- 23. IOS设置单元格高度取决于url图像高度宽度比率
- 24. 相同的CSS为两个表,但单元格宽度不同
- 25. HTML5表格单元格/行与其他宽度相同
- 26. 动态显示带有boundRectWIthSize的表格单元格高度
- 27. 显示器的高度问题:表格单元格
- 28. 不同表中的表格单元格宽度不一致
- 29. Sass/CSS网格和相同的高度/宽度
- 30. 将画布划分为相同宽度和高度的空格
对于使用自定义单元格或asynchrnousimageview提供帧。 –
manohar我是新来的,如果可能的话给我一个链接教程或代码.. – Ninja