我有一个我从未见过的非常奇怪的错误。我之前已经使用过这个代码数百次了,但由于某种原因,afterDelay被完全忽略了。
我的代码:
- (void)runIntro
{
if([self introDone])return;
UIImageView* back = [[UIImageView alloc] initWithFrame:[[AppDelegate shared] frame]];
[back setImage:[[AppDelegate shared] bgImage]];
[back setContentMode:UIViewContentModeScaleAspectFill];
[self.view addSubview:back];
UIImageView* target = [[UIImageView alloc] initWithFrame:CGRectMake(([[AppDelegate shared] width]-250)/2.0, ([[AppDelegate shared] height]-350)/2.0, 250, 72)];
[target setImage:[UIImage imageNamed:@"bpside.png"]];
[self.view addSubview:target];
Parabolic* wally = [[Parabolic alloc] initWithFrame:CGRectMake(([[AppDelegate shared] width]-200)/2.0, ([[AppDelegate shared] height]-314)/2.0+250, 200, 200)];
[wally setImage:[UIImage imageNamed:@"wallyside1.png"]];
[self.view addSubview:wally];
[self performSelector:@selector(moveWallyIntro:) withObject:wally afterDelay:1];
[self performSelector:@selector(moveWallyIntro:) withObject:wally afterDelay:2];
}
- (void)moveWallyIntro:(Parabolic*)wally
{
[wally runPBM:50 withDY:300 withDuration:0.5];
}
我知道所有其他代码都正常工作,但无论出于何种原因,选择器正在执行立即,这会导致严重问题。此代码在viewWillAppear
方法的末尾运行。我之前已经多次编程,这是我第一次看到这种情况。
更新:
如果我删除添加back
UIImageView的代码,这不再是一个问题。如何以这样的宽高比填充格式添加巨型图像(3000x2000),这样就不会导致程序挂起?我使用的是iphone,ipad等相同的背景图片,所以对于视网膜iPad来说它需要很大......