iPhone開発初心者です。iPhone シミュレーターを実行すると背景画像が範囲外になる Crystal Ball アプリのコードを書いています。私は実用的に物事をやろうとしています。以下はコードです
「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