Search code examples
iosobjective-cuiimageviewunrecognized-selector

Why an I getting "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImageView _isResizable]: unrecognized selector"


http://pt-br.tinypic.com/view.php?pic=300rxip&s=8#.VDhDStTF8mc

My UIImageView is connected to a TableViewCell as you can see above (my reputation is too low to post images, so I had to upload it on tinypic).

The cell code for this image is here:

#import <UIKit/UIKit.h>

@interface ExtratoDeNotasSideMenuTableViewCell : UITableViewCell

@property (strong, nonatomic) IBOutlet UIImageView *image;
@property (strong, nonatomic) IBOutlet UILabel *label;

@end

After that I specify which image it receives:

- (ExtratoDeNotasSideMenuTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    ExtratoDeNotasSideMenuTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ExtratoDeNotasSideMenuTableViewCell" forIndexPath:indexPath];

    // Configure the cell...
    cell.image.image = [UIImage imageNamed:@"Icone_SideBar.png"];
    cell.label.text = [NSString stringWithFormat:@"%@", [self.menuItens objectAtIndex:indexPath.row]];

    return cell;
}

But it doesn't work, the message: "*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImageView _isResizable]: unrecognized selector sent to instance 0x7fa81356da40'" keeps showing. Any help will be appreciated.


Solution

  • [UITableViewCell image] is a deprecated selector that is expected by the system to be a UIImage. You have overridden this name and returned a UIImageView instead, making the internal source that's expecting a UIImage fail.

    Solution: rename your image property.