首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >我在display字符串中有一些图像,我想在tableview中显示它。

我在display字符串中有一些图像,我想在tableview中显示它。
EN

Stack Overflow用户
提问于 2011-03-31 14:00:35
回答 1查看 53关注 0票数 0

我在resultstring中有一些图像,resultstring是我从服务器获得的,它包含图像,我想要这些图像并将其显示在表视图中

我的代码是

代码语言:javascript
运行
复制
viewdidload
{
NSString *urlVal = @"http://at.azinova.info/green4care/iphone/viewImage.php?id=";
    NSString *urlVal1 = [urlVal stringByAppendingString:selectedCountryw];
    NSURL *url1 = [NSURL URLWithString:urlVal1];
    //NSURL *url1 = [NSURL URLWithString:urlVal];



    NSString *resultString = [NSString stringWithContentsOfURL:url1 encoding:NSUTF8StringEncoding error:nil];


    NSArray *arycountries1 = [resultString componentsSeparatedByString:@","];
    UIAlertView *loginalert = [[UIAlertView alloc] initWithTitle:@" Message" message:resultString delegate:self
                                               cancelButtonTitle:@"OK" otherButtonTitles:nil];

    [loginalert show];

    [loginalert release];

    //arraycountries = [[NSArray alloc]initWitho:arycountries1];
    arraycountries = [[NSArray alloc]initWithArray: arycountries1];
    }

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
    return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    return [arraycountries count];
}


// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    cell.imageView.image = [UIImage imageNamed:[arraycountries objectAtIndex:indexPath.row]];
    // Configure the cell...

    return cell;
}

请帮帮忙

感谢

EN

回答 1

Stack Overflow用户

发布于 2011-03-31 14:58:16

你所描述的很像一个带有图片的消息栏,有一个twitter开源项目tweetero:http://code.google.com/p/tweetero/你可以看看MessageListController和ImageLoader。

通常,您可以这样做:

1)向服务器发送异步请求,获取消息日期(非图片)

2)重新加载表数据,并针对每个uiimageview发送镜像加载请求。

3)加载镜像时设置uiimageview。在加载真实图像之前,可以使用默认加载图像。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5495849

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档