+ Reply
Results 1 to 4 of 4

Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.


Thread: Simple app to display an image

is a discussion within the

iPhone / iPod Touch SDK | Development Discussion

forums, a part of the

3rd Party Apps For iPhone | iPod Touch

section;
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
...
  1. #1
    What's Jailbreak?
    Join Date
    Nov 2008
    Posts
    23
    Thanks
    0
    Thanked 1 Time in 1 Post
    Default Simple app to display an image
    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];

    }
    @end

  2. #2

  3. #3
    What's Jailbreak?
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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];

  4. #4
    iPhoneaholic
    Join Date
    Jun 2009
    Location
    Houston
    Posts
    321
    Thanks
    0
    Thanked 5 Times in 5 Posts

    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

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