gpt4 book ai didi

ios - TableView 显示项目中的图像

转载 作者:行者123 更新时间:2023-11-28 20:21:45 26 4
gpt4 key购买 nike

我正在尝试添加我在项目中添加的图像我使用以下代码

UIView *selectionView = [[UIView alloc] initWithFrame:CGRectMake(0, 7, 320, 50)];
[selectionView setBackgroundColor: [UIColor clearColor]];

UIImage *image = [[UIImage alloc]init];
image = [UIImage imageWithContentsOfFile:@"PlaceHolder.png"];
UIImageView* blockView = [[UIImageView alloc] initWithImage:image];
blockView.frame = CGRectMake(0, -5, 45, 45);

if([[[_arrayForTable valueForKey:@"URL"] objectAtIndex:[indexPath row]] isEqualToString:@"No Image"] )
{


[selectionView addSubview:blockView];


}
else
{
NSString *path = [[_arrayForTable valueForKey:@"URL"] objectAtIndex:[indexPath row]];

NSURL *url = [NSURL URLWithString:path];
AsyncImageView *imageView = [[[AsyncImageView alloc] init] autorelease];
imageView.frame = CGRectMake(0, -5, 45, 45);
imageView.imageURL=url;
[selectionView addSubview:imageView];


}

其他条件完美工作他们有 facebook 的 url 在表格 View 中显示图像但是如果条件不工作它进入如果条件但图像没有显示请帮助

最佳答案

UIImage *image = [UIImage imageNamed:@"PlaceHolder.png"];
UIImageView* blockView = [[UIImageView alloc] initWithImage:image];

/*
imageNamed: is to load the picture which is in bundle. pass in the picture name
imageWithContentsOfFile: need to pass in the whole address of the file
*/

关于ios - TableView 显示项目中的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15634529/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com