我有與圖像「ImageView的」一種方法:碰撞兩個圖像的,與所述宣言問題
- (void)createNewImageView {
// Get the view's frame to make it easier later on
UIImage *image = [UIImage imageNamed:@"abouffer_03.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
// Add it at a random point
[imageView setCenter:[self randomPointSquare]];
[[self view] addSubview:imageView];
// Animate it into place
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:8.0f];
[imageView setCenter:CGPointMake(240, 160)];
[UIView commitAnimations];
[imageView release];
}
和另一圖像「viewToRotate」(IBOuutlet在h和界面生成器定義)
而且我想用這種方法來檢查碰撞:
- (void)myRunloop
{
// check collision
if(CGRectIntersectsRect(imageView.frame, viewToRotate.frame))
{
viewToRotate.alpha=0.2;
}
}
但Xcode中總是給我的錯誤:「未申報的ImageView」,我不知道如何解決這個問題。我不想在這種方法中再次定義它。
坦克你,但你可以給我一個示例代碼或類似的東西,因爲我認爲我將無法做到你說的:/ –
我可以定義什麼animationDidStopSelector –
@jean mayot,對不起有點卡住了東西。我只是添加了一些示例代碼...希望能幫上忙 – Ahmed