使用NSString和UIImageView从URL加载图像,在某些URL上失败

时间:2010-08-27 15:57:38

标签: iphone objective-c nsstring nsdata nsurl

我有一些代码从URL加载图像,它似乎工作正常。除非URL包含大括号。这似乎是一个字符串格式问题?我无法理解。

离 @“http://site/image.png //有效

@“http://site/ {image} .png //不起作用

    NSString* mapURL = @"http://site.com/directory/{map}.png";
    NSLog(mapURL);
    NSData* imageData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:mapURL]];

    UIImage* image = [[UIImage alloc] initWithData:imageData];
    [imageView setImage:image];
    [imageData release];
    [image release];

感谢

1 个答案:

答案 0 :(得分:1)