【发布时间】:2013-03-10 07:16:32
【问题描述】:
我是 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
【问题讨论】:
-
到底是什么问题?
-
也许您使用的是高分辨率图像(用于视网膜显示),但您运行的是错误的 iphone sim 卡?图像文件夹中是否还有 Crystal_ball copy@.png?
-
不,我没有在图像文件夹中使用 crystal_ballcopy.png。我还需要使用什么样的图像来纠正这个问题。我想说的另一点是,当我在情节提要中使用图像视图时,相同的图像可以正常工作-但是当我尝试以编程方式执行相同操作时,问题就出现了
标签: iphone ios objective-c xcode