【发布时间】:2011-10-20 14:26:16
【问题描述】:
我在一个名为 aux 的字符串中有六个图像 URL。我用换行符分隔的组件拆分它。我想从aux 中一张一张地挑选图像,并将每个图像显示在ImageView 中。我的代码是:
aux = [_homeText.text stringByAppendingString:[NSString stringWithFormat:@" %@ ",item.shortDescription]];
[_homeText setText:aux];
NSString *list =aux;
NSArray *listItems = [list componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
[listItems count];
if ([listItems objectAtIndex:0]) {
NSURL *url = [NSURL URLWithString:aux];
/*UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"hai" message:aux delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil];
[alert show];
[alert release];*/
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *image = [[UIImage alloc] initWithData:data];
[_homeImage setImage:image];
}
else if ([listItems objectAtIndex:1])
{
NSURL *url = [NSURL URLWithString:aux];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *image = [[UIImage alloc] initWithData:data];
[_homeImage setImage:image];
}
没有错误,但我没有得到图像。为什么?我该如何解决这个问题?
【问题讨论】:
-
@Vladimer 对此的任何解决方案
-
@Vladimir 解决我的问题
-
尝试调试您的代码并检查您在字符串中实际得到的值
标签: objective-c uiimage nsdata nsurl