我在resultstring一些图片,我想在tableview中显示它
问题描述:
我在resultstring一些图像,resultstring是我从服务器获取,它包含图像,我想,图像和实现代码如下我在resultstring一些图片,我想在tableview中显示它
显示它我代码是
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;
}
请帮助
thankzzzzz
答
你所描述的很像用图片的邮件BORAD,有一个Twitter开源PROJ ect tweetero:http://code.google.com/p/tweetero/你可以看看MessageListController和ImageLoader。
在一般情况下,你可以这样做:
1)发送异步请求给服务器,以获得消息日期(不是图像)
2)重新加载表数据,并发送每个UIImageView的图像加载请求。
3)设置图像加载时的uiimageview。可以使用默认的加载图像,直到加载实际图像。