开发者

Basic Objective C Code Problem

In my grid class I have the constructor:

 - (id) init
{
    if ( self = [super init] )
    {

        isOccupied = NO;
        gridImage = [[UIImage alloc] initWithContentsOfFile:@"grid.png"];


    }
    return self;
}

I set gridImage as a property.

In my viewController I have:

UIImageView *temp = [[UIImageView alloc]initWithFrame:CGRectMake(10,10,200,200)];
[temp setImage: myGrid.gridImage];
[self.view addSubview: temp];

myGrid is an instance of the Grid Class... but it doesn't display? when I directly enter the file name it works, but not when i use properties to access. Can anyone help please?

my grid header开发者_开发百科:

@interface Grid : NSObject {


//Locations *locations[20][20];
BOOL isOccupied;
UIImage *gridImage; 
//Locations *mergedlocations[20][20];   


}
@property (retain) UIImage *gridImage

;


can you set the image this way using retain?

gridImage = [[UIImage imageNamed:@"grid.png"] retain];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜