2012-07-24 80 views
0

我的场景,在其中我在TableViewCell使用选择的波纹管,当我在我看来,单击后退按钮我要取消选择,我在选择发送词典作为对象取消选择在UITableViewCell中

我的代码波纹管

在头文件

NSMutableDictionary* photoDict; 
NSMutableDictionary* dictImages; 

在.m文件

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    NSString *cellIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 
    if(cell==nil) 
    { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellIdentifier]; 
     [[NSBundle mainBundle]loadNibNamed:@"MyCellNib" owner:self options:Nil]; 
     cell = detailChainObj; 
    } 

    NSString* avatarURL [email protected]"image_Url"; //Any url of image for cell. 
    NSString *key =[[NSString alloc] initWithFormat:@"Key%d%d",indexPath.section,indexPath.row]; 

    dictImages = [NSDictionary dictionaryWithObjectsAndKeys:imageViewCell,@"Img",imgURL,@"imgURL",key,@"key", nil]; 
    [self performSelectorInBackground:@selector(DownloadLinkzImageOfUser:) withObject:dictImages]; 


    if([photoDic valueForKey:keyAvt]) 
    { 
     NSData* data = (NSData*)[photoDic valueForKey:key]; 
     imageViewCell.image = [UIImage imageWithData:data]; 
    } 
    else 
    { 
     [self performSelectorInBackground:@selector(DownloadImagesForCell:) withObject:dictImages]; 
    } 
} 


// 

-(void)DownloadImagesForCell:(NSDictionary *)result 
{ 
    UIImageView* img = (UIImageView*)[result objectForKey:@"Img"]; 
    NSString* urlAvt = [result valueForKey:@"imgURL"]; 
    if([urlAvt isEqualToString:@"No Image"]) 
    { 
     img.image = [UIImage imageNamed:@"noimg.png"]; 
    } 
    else 
    { 
     NSData* data = [NSData dataWithContentsOfURL:[NSURL URLWithString:imgURL]]; 
     img.image = [UIImage imageWithData:data]; 
     [photoDic setValue:data forKey:[NSString stringWithFormat:@"%@",[result valueForKey:@"key"]]]; 
    } 
} 

现在我想,当我按后退按钮

取消此selecter并请记住,我已经使用

[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(DownloadImagesForCell:) object:dictImages]; 
+0

即使使用取消请求后,您是否选择器被调用? – vishy 2012-07-24 06:46:32

+0

雅我认为与我通过取消选择器方法的对象的问题。 – iDhaval 2012-07-24 06:49:36

+0

'DownloadImagesForCell'在主UI线程的不同线程上工作,对吧?如果你已经从主线程调用'cancelPreviousPerformRequestsWithTarget',那么我认为它不会工作... – tipycalFlow 2012-07-24 07:12:47

回答

相关问题