Setting size of UIImageView in a UITableView cell programmatically - what is the origin?

Not sure what there is so special about iOS. Just use the same method you use with 3.2: imageNamed: ... it will take care of everything as long as your images are named properly (yourimagename. Png and yourimagename@2x.

Png). Nothing fancy in the iOS 4 SDK here, just give the size you use in points as before If this is not suitable in your case, can you explain why?

Not sure what there is so special about iOS. Just use the same method you use with 3.2: imageNamed: ... it will take care of everything as long as your images are named properly (yourimagename. Png and yourimagename@2x.

Png). Nothing fancy in the iOS 4 SDK here, just give the size you use in points as before. If this is not suitable in your case, can you explain why?

Yes Eiko. The problem here is I am retrieving the image from a web server so I can dynamically change the image. The image I am sending is at the resolution I want to display on the iPhone 4 (e.g.My UIImageView in IB is 100 by 100 pixels and I am sending down an image that is 200 by 200 pixels).

I tried sending down the image with the @2x suffix, but it didn't help. Would a solution be to send down two versions of the image, store them locally and then load it? – mark Sep 11 '10 at 23:15 Hmm... "maybe".

Downloading the image, saving it and using imageNamed: should work (don't use the @2x extension in that method, just the plain name). You should also be able to set the scale factor of the image manually. – Eiko Sep 12 '10 at 6:12 Setting the scale manually is a 4.0 SDK feature.

:/ – mark Sep 12 '10 at 7:08 But there are no devices – Eiko Sep 12 '10 at 16:07 I think you're confusing the SDK version with the OS version. IOS 4.0 (the OS) can run apps written using only the 3.2 SDK. Yet, I don't have access to all the nice functionality that is useful for retina displays in the 3.2 SDK even though I am running my apps on iOS 4.0+ devices.

– mark Sep 12 '10 at 19:37.

I'm trying to display a high-res image on an iPhone 4 without using the iOS 4 SDK (only using 3.2 SDK API calls) Ouch. Don't do that. Compile against 4.0, set the deployment target to 3.whatever.

When creating the image, check UIImage respondsToSelector:@selector(imageWithCGImage:scale:orientation:). If it does, then you can use +UIImage imageWithCGImage:scale:orientation: to create a "scale 2" image, which will display correctly in a UIImageView on iPhone 4 (which has a "scale 2" screen). If you really can't use the OS 4 SDK (you don't seem to state a reason why), then make the UIImageView smaller using the appropriate content mode (AspectFit/AspectFill/ScaleToFill), and set its frame to half the size in pixels (e.g. If the image is 100x100 px, set it to (CGSize){50,50}).

This shrinks the image to half-size, but the double-res screen means you see it pixel-for-pixel.

If I use the 4.0 SDK, it enables backgrounding which breaks some functionality in my app. So I have to build and use the 3.2 SDK for now. Can you give me an example of your method for not using the OS 4 SDK?

Thanks! – mark Sep 12 '10 at 6:52 If app backgrounding is the only thing that you don't want in 4.0, just set UIApplicationExitsOnSuspend in Info.plist. – tc.

Sep 12 '10 at 12:55 Thanks tc - that looks interesting. Would it be okay for you to edit your post and show me an example of your no-4.0 SDK solution? Am I doing everything you specify if I am running on an iPhone 4?

Which UIImageView do I change? The one in IB or programmatically when I check to see if I am running on an iPhone 4? – mark Sep 12 '10 at 20:03.

I think your approach is wrong. IPhone 4 works with points instead of pixels, which makes doubling the size troublesome. 1 point on old devices equals 4 pixels on iPhone 4, but is still used as 1 point.

When you create the frame you're not actually giving the API the pixel dimensions, but the point dimensions.

– mark Sep 11 '10 at 21:17 Except an iPhone "point" is a lot smaller than the standard (PostScript) point of 1/72 inches. While Apple may call it a "point", it's a terrible name. – tc.

Sep 12 '10 at 5:20.

If it does, then you can use +UIImage imageWithCGImage:scale:orientation: to create a "scale 2" image, which will display correctly in a UIImageView on iPhone 4 (which has a "scale 2" screen). If you really can't use the OS 4 SDK (you don't seem to state a reason why), then make the UIImageView smaller using the appropriate content mode (AspectFit/AspectFill/ScaleToFill), and set its frame to half the size in pixels (e.g. If the image is 100x100 px, set it to (CGSize){50,50}). This shrinks the image to half-size, but the double-res screen means you see it pixel-for-pixel.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions