我想簡單地有一個循環,以便一個對象在底部不斷移動屏幕。這是我的代碼,它應該很容易理解。使對象在屏幕上移動iphone?
@interface ViewController()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self performSelector:@selector(spawnRocket) withObject:self afterDelay:2]; //delay before the object moves
}
-(void)spawnRocket{
UIImageView *rocket=[[UIImageView alloc]initWithFrame:CGRectMake(-25, 528, 25, 40)]; //places imageview right off screen to the bottom left
rocket.backgroundColor=[UIColor grayColor];
[UIView animateWithDuration:5 animations:^(){rocket.frame=CGRectMake(345, 528, 25, 40);} completion:^(BOOL finished){if (finished)[self spawnRocket];}]; //this should hopefully make it so the object loops when it gets at the end of the screen
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
做這一切後,我點擊運行,所有我看到的是一個白色的屏幕上我的iPhone 6.0模擬器
PS。即時運行xcode 4.5.1
也,我有兩個帳戶已經幾個月前,他們被禁止,因爲我問的壞問題。我不確定你是否被允許在stackoverflow上擁有多個賬戶,所以如果你不被允許,我在這裏被禁止,我不會再做賬了。雖然我意識到這個網站是多麼重要,我不會做任何不必要的問題。 –
可能值得提供如何創建'ViewController',這可能是一個問題。 – WDUK