我是 iPhone 开发的新手。我正在为 Crystal Ball 应用程序编写代码,当我运行 iPhone 模拟器时,其中的背景图像超出了范围。我正在努力务实地做事。以下是代码
导入“ViewController.h”
@interface ViewController ()
@end
@implementation ViewController
@synthesize predictionLabel;
@synthesize predictionArray;
- (void)viewDidLoad
{
[super viewDidLoad];
UIImage *image = [UIImage imageNamed: @"crystal_ball copy@2x.png"];
UIImageView *imageView =[[UIImageView alloc] initWithImage:image];
[self. view insertSubview:imageView atIndex:0];
self.predictionArray = [[NSArray alloc] initWithObjects:@"It is decideley so",
@"good things coming",
@"Good time is here",
@"Great profit",
@"stay possitive",@"Stay Foccused",@"all is well",nil];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[self setPredictionLabel:nil];
[self setPredictionLabel:nil];
[self setPredictionLabel:nil];
[self setPredictionLabel:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
- (IBAction)buttonPressed:(UIButton *)sender {
NSUInteger index = arc4random_uniform(self.predictionArray. count);
self.predictionLabel.text = [self.predictionArray objectAtIndex: index];
}
@end