Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

UIImageView shows in simulator, does not show on device

hermonirhermonir Posts: 17Registered Users
Hello,

I have a UIScrollView that has three view controllers added to it, as such:

	[scrollView addSubview:islandViewController.view];


On one of them, I'm adding three images in viewDidLoad:

- (void)viewDidLoad {
[super viewDidLoad];

CGRect myImageRect = CGRectMake(0.0f,0.0f, 320.0f, 480.0f);
UIImageView *sky = [[UIImageView alloc] initWithFrame:myImageRect];
[sky setImage:[UIImage imageNamed:@\"sky.png\"]];
sky.opaque = YES; // explicitly opaque for performance
[self.view addSubview:sky];
[sky release];

CGRect myImageRect3 = CGRectMake(0.0f,432.0f, 320.0f, 48.0f);
UIImageView *sea = [[UIImageView alloc] initWithFrame:myImageRect3];
[sea setImage:[UIImage imageNamed:@\"sea.png\"]];
sea.opaque = NO;
[self.view addSubview:sea];
[sea release];

CGRect myImageRect2 = CGRectMake(40.0f,365.0f, 241.0f, 101.0f);
UIImageView *island = [[UIImageView alloc] initWithFrame:myImageRect2];
[island setImage:[UIImage imageNamed:@\"island.png\"]];
island.opaque = NO;
[self.view addSubview:island];
[island release];

}


When I'm running it on the simulator all images are shown fine. When building and running on the device, only the "sea" image is shown.

I've tried cleaning and re-building, changing the order of the images, looking for lowercase/uppercase issues... All seems fine.
What could be the problem, and more importantly, how could this be fixed?

Thanx in advance,
Nir.
Post edited by hermonir on

Replies

  • smithdale87smithdale87 Posts: 4,292iPhone Dev SDK Supporter
    When I've had problems like this, that were not related to spelling/capitalization, it's usually due to a corrupt image. I just open the .png in a graphics editor and resave it as the same name. Sometimes I guess the png gets corrupted where the simulator can still read it, but not the device.
  • hermonirhermonir Posts: 17Registered Users
    smithdale87;180829 said:
    When I've had problems like this, that were not related to spelling/capitalization, it's usually due to a corrupt image. I just open the .png in a graphics editor and resave it as the same name. Sometimes I guess the png gets corrupted where the simulator can still read it, but not the device.
    Maybe I should try with jpegs, just to see what happens.
  • CoriCori Posts: 8New Users
    Got the same frustrating issue -got 3 PNGs on UIImage, shows on simulator, but not on device. And it used to show on the device, modified the code, reinstalled on the device and it stopped showing.

    The thing that's weird, I copied this program to Prog B, copied the same 3 PNGs and given different names, plus 2 more PNGs for Prog B. On the simulator, Prog A and Prog B PNGs show up, but on the device, only Prog B images, not Prog A!! Take note, I use the same UIViewController: Prog A and Prog B calls the same UIViewController, the only thing different is Prog A and Prog B pass a different filename prefix to the controller. I'm so stumped!! :confused::rolleyes:
  • baja_yubaja_yu Posts: 6,166Super Moderators, Registered Users
    Are the filenames correct? And keep in mind the filesystem on device is case sensitive. "Test.png" and "test.png" would be two different files on a device.
  • CoriCori Posts: 8New Users
    You're right baja_yu - it's filename but stupid me, it's the file prefix I passed! I missed 1 letter: UguidePage - g should have been a CAP. That's why it's a consistent bug!! :D Duh!!
  • xjulianxxjulianx Posts: 1New Users
    baja_yu;369834 said:
    Are the filenames correct? And keep in mind the filesystem on device is case sensitive. "Test.png" and "test.png" would be two different files on a device.
    a millions thanks, u saved my life! :)
  • jrt01ukjrt01uk Posts: 1New Users
    I just encountered a very similar problem; thought I'd share to save someone else wasting an hour like I just did trying to solve the problem!

    [email]image@2X.png[/email] is NOT the same as [email]image@2x.png[/email] :D
  • Duncan CDuncan C Posts: 8,031Tutorial Authors, Registered Users
    jrt01uk;406926 said:
    I just encountered a very similar problem; thought I'd share to save someone else wasting an hour like I just did trying to solve the problem!

    [email]image@2X.png[/email] is NOT the same as [email]image@2x.png[/email] :D
    I wonder how many thousands of programmer-hours us iOS developers have wasted because of the case-sensitivity of the iOS file system. I would cheerfully strangle the developer at Apple that decided to make the case sensitivity of iOS different from Mac OS (and thus different from the simulator.) I personally think case sensitive filenames are a very, very bad idea.

    My other pet peeve is the screwed up coordinate system in the graphics engine in iOS. Mac OS consistently places 0,0 at the lower left, increasing as you to go up and to the right.

    iOS is MOSTLY upside-down from that, but it isn't even consistent with itself!!! UIKit objects place 0,0 at the top left, and CALayers place it at the bottom left! WTF?!? Again, the programmers responsible should be shot. (this is, of course, hyperbole. I'm not really advocating violence, just expressing frustration.)
    Regards,

    Duncan C
    WareTo

    mug

    Animated GIF created with Face Dancer, available for free in the app store.
Sign In or Register to comment.