0

解释我的问题有点复杂。我正在使用 FGallery 库https://github.com/gdavis/FGallery-iPhone,尤其是它从 URL 地址加载图像的功能。当我对 URL 路径进行硬编码时,它非常有效,但是当我将一个字符串变量传递给我创建的类时,它不起作用。我尝试调试它,似乎一切正常,有一个字符串分配给变量和所有内容,但不显示图片。我正在循环执行此操作并使用 ARC。

  -(void) loadSoftia
  {
     //======================================================================================
//THIS WORKS CORRECTLY!!!
wcSofia = [[NSMutableArray alloc] init];

Webcam *s1 = [[Webcam alloc]init];
s1.description=@"Sofia";
s1.location =  @"http://www.ampthillweatherstation.info/currentweather/webcamimage.jpg";
[wcSofia addObject:s1];
 //======================================================================================

NSMutableString *urlGetOthersLocations =[NSMutableString stringWithFormat:@"http://%@/WebHandlers/%@", @"192.168.188.204", @"BGCam.ashx"];

ServerResponse *serverResponseOthersLocations = [HelperViewController getJsonDataFromTheServer:urlGetOthersLocations];
if(serverResponseOthersLocations.data!=nil)
{
    NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:serverResponseOthersLocations.data
                                                        options:NSJSONReadingMutableLeaves|NSJSONReadingMutableContainers
                                                          error:nil];
    [wcSofia removeAllObjects];

    Webcam *wc;
    int i=0;
    for (NSDictionary *locationsDic in dic){

             NSString *key;
                   for ( key in locationsDic) {

                        NSLog(@"%@ = %@", key, [locationsDic objectForKey: key]);
                    }
                    NSLog(@"%@", [locationsDic objectForKey:@"URL"]);
                    NSLog(@"%@ = %@", locationsDic, [locationsDic objectForKey: locationsDic]);

        NSString *url =[locationsDic objectForKey:@"URL"];
        //            NSLog(@"%@", url);

        NSMutableString* theString = [NSString stringWithFormat:@"%i ",i];
        wc = [[Webcam alloc]initWithLocation: [NSString stringWithFormat:@"%@", url] withDescription:@"description"];
        wc.location = url;//DOESNT WORK!
    wc.description =@"София";// theString;//[NSString stringWithFormat:@"%@",  @"aa"]; // @"София";
      wc.location    = @"http://media.borovets-bg.com/cams/channel?channel=61";//IT WORKS BECAUSE IT IS HARDCODED

        if(wcSofia!=nil)
        {
            [wcSofia addObject:wc];
            NSLog(@"%@", wc.location);   
        }
        i++;

    }
    }

  }

我已经评论了一段有效的代码,哪些无效。我想你不需要整个程序,因为它会向我的本地 Web 服务器发出请求以获取 URL 地址和描述,但相信我,这东西完美无缺。感谢您帮助解开这个谜团。编辑:完整源代码:https ://dl.dropboxusercontent.com/u/46512232/FGallery.zip

4

0 回答 0