UITableView image causes crash - iphone

I've done a million UITables - with subtitles, images, backgrounds, colors, text-styles - you name it.
Suddenly, I'm crashing on this table, specifically on the line that calls for the image of the cell.
Here's the code:
// Configure the cell:
cell.textLabel.font = [UIFont fontWithName:#"Franklin Gothic Book" size:18];
cell.textLabel.text = [leadershipMenu objectAtIndex:indexPath.row];
cell.detailTextLabel.text = [leadershipSubtitlesMenu objectAtIndex:indexPath.row];
// And here's the statement that causes the crash:
cell.imageView.image = [leadershipPhotosMenu objectAtIndex:indexPath.row];
Now, the error I get is this:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[__NSCFConstantString _isResizable]: unrecognized selector sent to instance 0xcacbc'
I know for sure that the statement causing the crash is the
cell.imageView.image = ...
cause as soon as I comment it out everything works fine.
I've never in my life seen an
-[__NSCFConstantString _isResizable]:
error.
I've googled it but found very little on it.
Very peculiar.
Anyone out there got any clues?

as mentioned in your comment. the way you save your image is what causes the problem.
try this..
leadershipPhotosMenu = [[NSMutableArray alloc] initWithObjects:[UIImage imageNamed:#"JohnQ.jpg"], [UIImage imageNamed:#"BillZ.png"], nil];
the code above will store the images in your mutableArray, That will work but I suggest not to store the images in an array.
you can also solve your problem without storing your images in your array like the code above by doing:
cell.imageView.image = [UIImage imageNamed:(NSString*)[leadershipPhotosMenu objectAtIndex:indexPath.row]];
this error message means your object inside your leadershipPhotosMenu is not image, but string
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[__NSCFConstantString _isResizable]: unrecognized selector sent to instance 0xcacbc'

Do this:
cell.imageView.image = [UIImage imageNamed:[leadershipPhotosMenu objectAtIndex:indexPath.row]];

You are storing the name of the images ad not the images. However imageView has UIImage as its property and not the image name. So make below change.
cell.imageView.image = [UIImage imageNamed:[leadershipPhotosMenu objectAtIndex:indexPath.row]];

Related

UIImage Methods not getting called

I'm trying to manipulate UIImage Object on the view. But when I try to call any method on UIImage class, it throws exception
2013-02-14 15:24:42.301 Test[4685:19a03] -[UIImage scaleToSize:]: unrecognized selector sent to instance 0x94642c0
2013-02-14 15:24:42.303 Test[4685:19a03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImage scaleToSize:]: unrecognized selector sent to instance 0x94642c0'
*** First throw call stack:`
(0x1cc1012 0x1ae6e7e 0x1d4c4bd 0x1cb0bbc 0x1cb094e 0x47ee9 0x47bc0 0xb0f817 0xb0f882 0xb0fb2a 0xb26ef5 0xb26fdb 0xb27286 0xb27381 0xb27eab 0xb27fc9 0xb28055 0xc2d3ab 0xa7e92d 0x1afa6b0 0x5c3fc0 0x5b833c 0x5b8150 0x5360bc 0x537227 0x5378e2 0x1c89afe 0x1c89a3d 0x1c66f61 0x1c66e1b 0x39117e3 0x3911668 0xa2e65c 0x31fcd 0x29d5)
libc++abi.dylib: terminate called throwing an exception
Here's the code that I'm using:
UIImage *test = [[UIImage alloc] init];
test = [UIImage imageNamed:#"image0.jpg"];
[test scaleToSize:CGSizeMake(40.0f, 40.0f)];
Take a look at the UIImage's class reference. You won't find the method you are looking for. Maybe you forgot to add a category you are using like (for example):
#import "UIImage+Scale.h"
FIRST DEFINE THE IMAGE SIZE THEN SCALE IT.
UIImage *test = [[UIImage alloc] init;
test = [UIImage imageNamed:#"image0.jpg"];
[test scaleToSize:CGSizeMake(40.0f, 40.0f)];
Try this line of code.Or use this image in UIImageView

UIImageview set image crash

I'm setting image to a UIImageView using in the below code
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
for(int i=0;i<[radioButtons count];i++){
[[radioButtons objectAtIndex:i] setImage:[UIImage imageNamed:#"checkbox_unchecked.png"]];
}
UIImageView *imageViews=(UIImageView *)[self.view viewWithTag:indexPath.row];
[imageViews setImage:[UIImage imageNamed:#"checkbox_checked.png"]];
}
So on clicking any tableview cell the images gets sets. But once if I click on objectatindex:0
then the app crashes. I'm unable to fix this.
Below is the crash log:
2012-08-20 16:25:36.321 EventApp[2422:12503] -[UIView setImage:]: unrecognized selector sent to instance 0x79642b0
2012-08-20 16:25:36.321 EventApp[2422:12503] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setImage:]: unrecognized selector sent to instance 0x79642b0'
*** First throw call stack:
(0x1de3022 0x1c03cd6 0x1de4cbd 0x1d49ed0 0x1d49cb2 0x7a98c 0xc615c5 0xc617fa 0x14f685d 0x1db7936 0x1db73d7 0x1d1a790 0x1d19d84 0x1d19c9b 0x1be57d8 0x1be588a 0xbd0626 0x380a2 0x23b5)
terminate called throwing an exception(lldb)
I think you are not getting UIImageView Object,you are getting uiview types object that's why it crashes. you should try to Define another tag property like 999+indexPath.row. Got it somewhere you define the tag=0 or IB automatically takes tag=0 to all object so it taking uiview with tag 0 not uiimageView
this means that you are sending message -(void)setImage to UIView, not to UIImageView. Make sure that view with tag indexPath.row and all radioButtons in array are actually UIImageView

App Crashing when returning from background

My application is crashing when it returns back from the background at certain places:
-[UITableViewCellContentView updateToInterfaceOrientation]: unrecognized selector sent to instance 0x165470
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewCellContentView updateToInterfaceOrientation]: unrecognized selector sent to instance 0x165470'
The error is always similiar somtimes its with
[UIScrollViewDelayedTouchesBeganGestureRecognizer updateToInterfaceOrientation]
I'm really clueless as to why this is happening, any help would be much appreciated.
EDIT:
Ok, this is how I am creating my table view in the loadView method:
int tableCells = [formDS.tableItems count];
int tableHeight = FORM_TABLE_CELL_HEIGHT * (tableCells);
UITableView *table = [[UITableView alloc] initWithFrame:CGRectMake(0, yCoord, FORM_TABLE_WIDTH, tableHeight) style:UITableViewStyleGrouped];
[table setBackgroundView:nil];
table.backgroundView.backgroundColor = UIColorFromRGB(FORM_BODY_COLOR);
table.backgroundColor = UIColorFromRGB(FORM_BODY_COLOR);
table.dataSource = self;
table.delegate = self;
[localContainerView addSubview:table];
It looks like you have some released object and because of that some other objects now present at the same address in memory receive the call for updateToInterfaceOrientation.
Try hitting COMMAND + SHIFT + B (or go to Product -> Analyze in XCode's top bar menu) to have XCode make a static analyze of your code and get some hints of what might go wrong.
Hope that's going to help!

[__NSArrayM synchronize]: unrecognized selector exception

I used some NSMutableArray with UIImageView objects.
When I quit the app I get this exception message:
[__NSArrayM synchronize]: unrecognized selector sent to instance 0x4b3a910
In AppDelagate.m
NSMutableArray * aViewArray;
...
currentView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:displayImageNamed]];
[aViewArray addObject:currentView];
[currentView release];
In ViewController.m
UIImageView *myImage = [aViewArray objectAtIndex:i];
myImage.xxx = yyy ;
Looking at your comment regarding NSUserDefaults, you should not be releasing both languages and defaults since you don't have ownership (you didn't alloc/init them). Try removing those two calls to release and see if that resolves your issue.

iPhone dev question help forming array

I've spent this morning searching google for this, but I just can't get what I want how i want it.
I am creating a custom table view cell, with different icons down the side, in a sectioned table view. My problem is that I am having trouble reading these images from an array.
I can do it like below, but can someone please help me do this from an array.
Working Long Form Code:
switch (indexPath.row) {
case 0:
imageView2.image = [UIImage imageNamed:#"ico-company.png"]; break;
case 1:
imageView2.image = [UIImage imageNamed:#"ico-value.png"];
case 2:
imageView2.image = [UIImage imageNamed:#"ico-date.png"]; break;
case 3:
imageView2.image = [UIImage imageNamed:#"ico-notes.png"];break;
default:
break;
}
And i think i can get it to look something like:
Not Working Code how i want
arryImages = [[NSMutableArray alloc] init];
arryImages = [NSArray arrayWithObjects:
[UIImage imageNamed: #"ico-company.png"],
[UIImage imageNamed: #"ico-value.png"],
[UIImage imageNamed: #"ico-date.png"],
[UIImage imageNamed: #"ico-notes.png"], nil];
imageView2.image = [UIImage imageWithContentsOfFile:[arryImages objectAtIndex:[indexPath row]]];
And this is the error i get when i try my array code:
2010-01-18 13:20:47.314 SQL[60921:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIImage length]: unrecognized selector sent to instance 0x39135c0'
Regards
Your last line should actually be:
imageView2.image = [arryImages objectAtIndex:[indexPath row]];
(in your code, you're passing an image object to imageWithContentsOfFile, but that method expects a filename, not an image object)