1. Miniver Cheevy's Avatar
    I just want to make a simple app to display my college schedule contained in a PNG when I tap the icon. The file is in the folder and called "s.png". My code does not display the image; the program compiles but does notihng when launched, it just sits there at a black screen until i hit the home button. Can anyone tell me what I'm doing wrong? My experiencw with ObjC is limited and thus, I'm using an existing HelloWorld app as a template to accomplish my goal. (I do not intend to publicly release the program in the interest of code originality.)

    #import "HelloWorldApp.h"

    @implementation HelloWorldApp
    - (void) applicationDidFinishLaunching: (id) unused
    UIWindow *window;

    window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    myImage = [UIImageView alloc];
    initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 480.0f);
    [myImage setImage:[UIImage imageNamed:@"s.png"]];

    mainView = [[UIView alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
    [mainView addSubview:myImage];

    [window makeKeyAndVisible];
    [window addSubview: mainView];

    2009-09-06 01:18 AM
  2. gojohnnyboi's Avatar
    I think a better solution would be to display what you need in a UITableView.
    iPhone Developer

    Twitter: @Gojohnnyboi
    Email: [email protected]

    Anthrax ram disk kit developer, hacker.
    2009-09-06 04:18 PM
  3. Jarfilli's Avatar
    CGRect myImageRect = CGRectMake(0.0f, 0.0f, 320.0f, 109.0f);
    UIImageView *myImage = [[UIImageView alloc] initWithFrame:myImageRect];
    [myImage setImage:[UIImage imageNamed:@"s.png"]];
    myImage.opaque = YES; // explicitly opaque for performance
    [self.view addSubview:myImage];
    [myImage release];
    2009-10-25 07:01 AM
  4. ronblade's Avatar
    It can be done without any coding and I think that should be better than anything.Drag an image from the finder to the resources section of the project outline. Xcode infers the action from the file type, and images will be copied to the Resources folder.
    Once the image is added to your project, the UIImageView inspector image name will autocomplete your image name, and all should work.
    mod/edit links removed
    2009-10-25 11:59 AM