-1

我正在使用此代码通过网络服务加载图像和文本...能够获取文本但不能获取图像...任何人都可以帮助我...请

NSString *append=[NSString stringWithFormat:@"%@",[[paiddic objectAtIndex:indexPath.row]objectForKey:@"grp_image_path"]];
NSString *myString = @"http://192.168.1.121/iptv_09042013/";
NSString *test = [myString stringByAppendingString:append];
NSString *str = [test stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSLog(@"%@",str);
NSData* imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:str]];
UIImage* image1 = [UIImage  imageWithData:imageData];
NSLog(@"Loaded Image: %@", image1);

if (image1 == nil)
{
    cell.photoView.image = [UIImage imageNamed:@"$.png"];
    // cell.titleLabel.text = [[paiddic objectAtIndex:indexPath.row]objectForKey:@"group_name"];
}
else
{
    cell.photoView.image = image1;
}
cell.titleLabel.text = [[paiddic objectAtIndex:indexPath.row]objectForKey:@"group_name"]; 
4

1 回答 1

0

更改次要并检查...

NSString *str = [append stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
    NSLog(@"%@",str);
    NSData* imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:str]];
    UIImage* image1 = [UIImage  imageWithData:imageData];
    NSLog(@"Loaded Image: %@", image1);

    if (image1 == nil)
    {
        cell.photoView.image = [UIImage imageNamed:@"$.png"];
       // cell.titleLabel.text = [[paiddic objectAtIndex:indexPath.row]objectForKey:@"group_name"];
    }
    else
    {
    cell.photoView.image = image1;
    }
    cell.titleLabel.text = [[paiddic objectAtIndex:indexPath.row]objectForKey:@"group_name"]; 
于 2013-05-02T10:31:33.330 回答