codes for "Hit to display an image"

Discussion in 'iOS Programming' started by zayjay, Jul 2, 2009.

  1. zayjay macrumors member

    zayjay

    Joined:
    Jul 24, 2008
    Location:
    Hangzhou
    #1
    Hi, I'm a beginner for coding and what I'm trying to do is extremely simple:
    Hit the bottom to display an image, I know my codes will look stupid, but pls
    help me improving, thank you all in advance:

    #import "MainView.h"
    @implementation MainView;

    -(void)awakeFromNib;
    {
    UIImage *sampleimage = [[UIImage imageNamed:mad:"box.jpg"] retain];
    pic = [[UIImageView alloc]init];
    pic.image = sampleimage;
    [sampleimage release];
    [pic release];

    -(IBAction)hit;
    {
    [pic awakeFromNib];
    }

    @end
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    Four things:
    1) "Hit the bottom" of what?
    2) Why are you releasing pic?
    3) Don't call your method awakeFromNib. Could be confused with the UIKit method.
    4) Use the [ CODE ][ /CODE ] tags (removing the spaces) to enclose code snippets. These tags can be accessed via the # icon in the toolbar.
     

Share This Page