views:

122

answers:

2

In my application, I would like a modal view to present itself when the app starts up and there is no wifi. I have code like this in the applicationDidFinishLaunching:

UIViewController *modalViewController = [[UIViewController alloc] initWithNibName:@"ModalDisconnect" bundle:nil];
[[self tabBarController] presentModalViewController:modalViewController animated:YES];
[modalViewController release];

The nib here is simply a UIView with a UIImageView nested inside.

Question: On the device, the image comes up and is 2x the width of the screen (I can only see the left half). Why could this happen? On the simulator everything works as planned.

+1  A: 

The only thing i can think of here is that you have your UIImageViews Image setting the bounds, So if you are initializing UIImageView w ith [UIImageView initWithImage:], this will cause the ImageView to take the dimensions of the image, and if the image was taken in landscape mode then it will strech the view. As a solution, set your UIImageView r ectangle and then s et the image something like

[[UIImageView alloc] initWithFrame:frame] 
 [imageView setImage:image]
Daniel
I'll give this a shot (in about 7 hours), as I had a similar inclination. The thing that confuses me is that this all being done in the nib, and the image is exactly the correct size: 320x460 and the dimension properties I set for it are equivalent.
TahoeWolverine
Okay, so in investigating the frame, it thinks that it is 320x460. This means that it probably thinks it is displaying the image normally, but somewhere along the way the image changes. The one flag that I see is that the image appears to have 1 px image, 1 px blank/white in vertical lines. I guess that's what you would expect, but it is strange. I'm going to try using the same image elsewhere to prove that it's not just the .png file.
TahoeWolverine
+1  A: 

The problem was caused by using a .png that was generated from a .psd (photoshop) that had a number of layers including text, pictures, and gradients. Some combination of these tricked my ipod into rendering the image in a strange way. I flattened the .png in photoshop and then it worked perfectly.

Thanks for the help.

TahoeWolverine