0
我想訪問一個UIImage實例變量並顯示它在UIImageView。當我嘗試NSLog的路徑時,我得到空。我可以手動顯示通過IB一個事先知情同意,但我想通過嚴格的代碼訪問UIImage實例變量,並顯示它在UIImageView
#import "Deck.h"
#import "Card.h"
@implementation Deck
@synthesize cards;
- (id) init
{
if(self = [super init])
{
cards = [[NSMutableArray alloc] init];
NSInteger aCount, picNum = 0;
for(int suit = 0; suit < 4; suit++)
{
for(int face = 1; face < 14; face++, picNum++)
{
NSString *fileName = [NSString stringWithFormat:@"card_%d", picNum];
NSString *path = [[NSBundle mainBundle] pathForResource:fileName
ofType:@"png"inDirectory:@"/cards"];
NSLog(@"%@", path); //outputs correctly
UIImage *output = [UIImage imageNamed:path];
NSLog(@"%@", output); //outputs null
Card *card = [[Card alloc] initWithFaceValue:(NSInteger)face
countValue:(NSInteger)aCount
suit:(Suit)suit
cardImage:(UIImage *)output];
[cards addObject:card];
}
}
}
return self;
}
我添加了一個鏈接顯示在圖片中發現
任何建議 – blitzeus