iosuiimageviewselectorsettext

[UIImageView setText:]: unrecognized selector sent to instance


I'm sorry if it has already been asked, but here comes the problem:

I get this message when I scroll fast the tableView :

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImageView setText:]: unrecognized selector sent to instance 0x8a8f8d0'

Here is my code :

   NewsVideoCell *cell = [tableView dequeueReusableCellWithIdentifier:AudioCellIdentifier];

   if (cell == nil) {
       cell = [[NewsVideoCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:AudioCellIdentifier];
   }


   cell.backgroundView = [ [UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"news_bg"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 0, 10, 0)] ];  
   cell.selectedBackgroundView = [ [UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"news_bg"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 0, 10, 0)] ];



   UILabel *cellLabel = (UILabel *)[cell viewWithTag:1];
   [cellLabel setText:[masjid objectForKey:@"name"]];

   UILabel *cellDate = (UILabel *)[cell viewWithTag:2];
   [cellDate setText:[[news objectAtIndex:indexPath.row] objectForKey:@"date"]];       

   UIImageView *cellImage = (UIImageView *)[cell viewWithTag:3];
   NSString *imagePath = [masjid objectForKey:@"thumb"];
   [cellImage setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@", imagePath]]];

   UITextView *cellText = (UITextView *)[cell viewWithTag:5];
   NSString *postText = [[news objectAtIndex:indexPath.row] objectForKey:@"title"];

   [cellText setText:postText];

   ...

And the line which fire this exception is :

   [cellText setText:postText];

I saw that it's due to an over-retaining or under-releasing, but I don't find a way to fix it.

any help plz ?


Solution

  • UITextView *cellText = (UITextView *)[cell viewWithTag:5];
    

    in this line of code your TAG for UITextView is "5", i think you may have given diffrent ID for this View . First .

    i had similler problem .... i found that my Tag Was diffrent for TextView and Image View .

    how to Change TAG for a View ?

    First select the View(ie UITextView) and than go to Attribute inspector Tab ..... Under the ' View ' you will find 'TAG' write there 5.