【发布时间】:2016-01-25 22:33:37
【问题描述】:
我一直按照“通过开发 iPhone 游戏学习 Objective-C”一书中对 Alien Invaders 的说明进行操作。
我在.m文件中输入了以下代码,然后书上告诉我运行以下代码:
@interface GameViewController ()
@property (strong) UIImage *playerImage;
@property (strong) UIImageView *playerView;
@end
@implementation GameViewController
- (void)viewDidLoad {
[super viewDidLoad];
//Assign an image to a variable
self.playerImage = [UIImage imageNamed:@"ship.png"];
//Create an image view and start it up with out image
self.playerView = [[UIImageView alloc] initWithImage: self.playerImage];
//Set the image views bounding rectangle to scale the image.
self.playerView.frame = CGRectMake(50,400, 32,32);
//Show the image on the screen.
[self.view addSubview: self.playerView];
}
}
我尝试在模拟器中运行代码,但出现以下错误。为什么会这样?
Alien-Invaders[565:10012] Could not load the "backdrop.png" image referenced from a nib in the bundle with identifier "Chris.Alien-Invaders"
【问题讨论】:
标签: ios objective-c iphone uiimageview nib