Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Nov 5, 2009, 09:29 PM   #1
ArtOfWarfare
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
Property Chains?

Right now I have a table view with several cells. Each cell has an image in it that's a different size. It's unattractive so I want to change them so they all crop the images to be the same size.

The code I'm trying to do this with is...

Code:
	cell.imageView.image = [UIImage imageNamed:[NSString stringWithFormat: @"%@.jpg", cell.textLabel.text]];
	cell.imageView.frame.size.width = 20.0;
	cell.imageView.frame.size.height = 20.0;
	cell.imageView.contentMode = UIViewContentModeScaleToFill;
It's selecting the correct image, and changing the content mode seems to work, but the images all have different widths and so the text labels don't line up right. How can I change all of them to have the same width?

(It gives me the error "Lvalue required as left operand of assignment" on the lines changing the width and height.)
__________________
Battery Status - On the Mac App Store
The only app that'll estimate when your wireless devices will need their batteries changed.
Including the ones paired with other Macs on your network.
ArtOfWarfare is offline   0 Reply With Quote
Old Nov 6, 2009, 09:18 AM   #2
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
frame is a CGRect struct and thus width and height cannot be assigned that way. Either try using CGRectMake or creating a CGRect from the frame, manipulating it, and then reassigning it.
__________________
dejo is offline   0 Reply With Quote
Old Nov 6, 2009, 02:37 PM   #3
ArtOfWarfare
Thread Starter
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
Thanks! It now compiles without any errors.

Unfortunately, it doesn't seem to have changed anything.

I am using this code:
Code:
    cell.textLabel.text = [users objectAtIndex:indexPath.row];
	cell.imageView.image = [UIImage imageNamed:[NSString stringWithFormat: @"%@.jpg", cell.textLabel.text]];
	cell.imageView.contentMode = UIViewContentModeScaleToFill;
	cell.imageView.bounds = CGRectMake(0,0,20,20);
	cell.imageView.clipsToBounds = YES;
but it's getting me these results:



I want the images to all be of the same size.

Also, something curious I found... changing the contentMode property would change how the images were positioned, but not what their dimensions were... IE, the picture for Colin would still be a long rectangle... if you think that's important but don't understand what I mean I can add a picture to explain it better...
__________________
Battery Status - On the Mac App Store
The only app that'll estimate when your wireless devices will need their batteries changed.
Including the ones paired with other Macs on your network.
ArtOfWarfare is offline   0 Reply With Quote
Old Nov 6, 2009, 02:55 PM   #4
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Yeah, I find I need to resize the image to be cropped as expected. I do this by using a protocol library for image resizing I got from About Objects, Inc. It can be found in the Editable TableView Example on this page.
__________________
dejo is offline   0 Reply With Quote
Old Nov 6, 2009, 08:37 PM   #5
ArtOfWarfare
Thread Starter
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
Thank you so much for the help!
Everything displays exactly as I expect and want it to!
__________________
Battery Status - On the Mac App Store
The only app that'll estimate when your wireless devices will need their batteries changed.
Including the ones paired with other Macs on your network.
ArtOfWarfare is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Are there two supply chains for the iPhone 5s? 1981d iPhone 1 Sep 26, 2013 06:27 AM
The Big Fast Food/Pizza Chains Should All Close MICHAELSD Community Discussion 40 Aug 30, 2013 12:14 AM
Cubetto EPK: Event-driven Process Chains on iPad johannesb iPad Apps 2 Apr 15, 2013 01:52 AM

Forum Jump

All times are GMT -5. The time now is 04:08 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC