2012-01-30 88 views
0

我使用在https://github.com/nicklockwood/AsyncImageView演示例子异步加载图像,但是我的应用崩溃时我加载应该加载图像使用AsyngImageView崩溃应用

视图
- (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]; 

     //common settings 
     cell.imageView.frame = CGRectMake(0.0f, 0.0f, 44.0f, 44.0f); 
     cell.imageView.contentMode = UIViewContentModeScaleAspectFill; 
     cell.imageView.clipsToBounds = YES; 
     cell.selectionStyle = UITableViewCellSelectionStyleNone; 
     cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; 
    } 

    //display image path 
    cell.textLabel.text = [nnameArray objectAtIndex:indexPath.row]; 

    //cancel loading previous image for cell 
    [[AsyncImageLoader sharedLoader] cancelLoadingURL:cell.imageView.imageURL]; 

    //set placeholder image or cell won't update when image is loaded 
    //cell.imageView.image = [UIImage imageNamed:@"placeholder.png"]; 

    //load the image 
    cell.imageView.imageURL = [pimgArray objectAtIndex:indexPath.row]; 

    return cell; 

    [cell release]; 
} 

pimgArray是URL的一个阵列来自XML文件。任何人都有一个想法,为什么这一个不工作?

cell.imageView.imageURL = [pimgArray objectAtIndex:indexPath.row]; 

控制台消息


[Session started at 2012-01-31 13:26:42 +0800.] 
2012-01-31 13:26:48.665 EteractApp[6024:207] -[NSCFString isFileURL]: unrecognized selector sent to instance 0x4e103e0 
2012-01-31 13:26:48.667 EteractApp[6024:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString isFileURL]: unrecognized selector sent to instance 0x4e103e0' 
*** Call stack at first throw: 
(
    0 CoreFoundation      0x00e885a9 __exceptionPreprocess + 185 
    1 libobjc.A.dylib      0x00fdc313 objc_exception_throw + 44 
    2 CoreFoundation      0x00e8a0bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187 
    3 CoreFoundation      0x00df9966 ___forwarding___ + 966 
    4 CoreFoundation      0x00df9522 _CF_forwarding_prep_0 + 50 
    5 EteractApp       0x00016f9d -[AsyncImageCache imageForURL:] + 63 
    6 EteractApp       0x000176f0 -[AsyncImageConnection isInCache] + 75 
    7 EteractApp       0x00018c4c -[AsyncImageLoader updateQueue] + 488 
    8 EteractApp       0x00019407 -[AsyncImageLoader loadImageWithURL:target:success:failure:] + 196 
    9 EteractApp       0x00019450 -[AsyncImageLoader loadImageWithURL:target:action:] + 65 
    10 EteractApp       0x00019be6 -[UIImageView(AsyncImageView) setImageURL:] + 93 
    11 EteractApp       0x0001a2ad -[MyMatches tableView:cellForRowAtIndexPath:] + 878 
    12 UIKit        0x00361b98 -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 634 
    13 UIKit        0x003574cc -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 75 
    14 UIKit        0x0036c8cc -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1561 
    15 UIKit        0x0036490c -[UITableView layoutSubviews] + 242 
    16 QuartzCore       0x01d9ca5a -[CALayer layoutSublayers] + 181 
    17 QuartzCore       0x01d9eddc CALayerLayoutIfNeeded + 220 
    18 QuartzCore       0x01d440b4 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310 
    19 QuartzCore       0x01d45294 _ZN2CA11Transaction6commitEv + 292 
    20 QuartzCore       0x01d4546d _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 99 
    21 CoreFoundation      0x00e6989b __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 27 
    22 CoreFoundation      0x00dfe6e7 __CFRunLoopDoObservers + 295 
    23 CoreFoundation      0x00dc71d7 __CFRunLoopRun + 1575 
    24 CoreFoundation      0x00dc6840 CFRunLoopRunSpecific + 208 
    25 CoreFoundation      0x00dc6761 CFRunLoopRunInMode + 97 
    26 GraphicsServices     0x017531c4 GSEventRunModal + 217 
    27 GraphicsServices     0x01753289 GSEventRun + 115 
    28 UIKit        0x002fac93 UIApplicationMain + 1160 
    29 EteractApp       0x00001c58 main + 102 
    30 EteractApp       0x00001be9 start + 53 
    31 ???         0x00000001 0x0 + 1 
) 
terminate called after throwing an instance of 'NSException' 
+2

你能有你得到的错误信息? “崩溃”有点模糊......顺便说一下,你应该“自动释放”你的单元格,释放函数在方法返回后不起任何作用(它从来没有达到过)。 – omz 2012-01-30 11:19:20

+0

是这个代码是从演示项目..它运行良好,在Xcode 3.2.6 – vishy 2012-01-30 11:22:08

+0

IM真的不知道怎么看的错误消息,他们说运行僵尸,但它在我的名单禁用,在运行 - 与性能工具运行。 http://stackoverflow.com/questions/5386160/how-to-enable-nszombie-in-xcode即时通讯使用xcode 4.3 – 2012-01-31 02:37:34

回答

1
cell.imageView.imageURL = [NSURL URLWithString:[pimgArray objectAtIndex:indexPath.row]]; 

我经过一个NSStringNSURL对象没有初始化它..

+0

男孩!你保存了我的生活! – WaaleedKhan 2014-08-13 15:17:45