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 601
 
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 601
 
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 601
 
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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
How to create a custom property and identifier? mandude iPhone/iPad Programming 2 Aug 12, 2011 01:37 PM
meddling with the responder chain MrFusion Mac Programming 5 May 14, 2011 06:06 PM
Intellectual Property NickZac Politics, Religion, Social Issues 10 Feb 3, 2011 09:56 PM
Accessing properties of properties luckylefty01 iPhone/iPad Programming 3 Jun 24, 2008 11:33 PM


All times are GMT -5. The time now is 07:57 AM.

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

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