我正在做一个小游戏,如果你赢了,它会显示一个图像。图像大小为全屏。我想让它成为当我tap在它上面时,它会删除和活动或viewController做一些事情并重新开始。
我有一个可以添加的想法,TAP Gesture recognizer但是我怎样才能popup在后台停止活动,然后在录制它之后做一些事情并重新启动Controller.
最好的祝福
我正在做一个小游戏,如果你赢了,它会显示一个图像。图像大小为全屏。我想让它成为当我tap在它上面时,它会删除和活动或viewController做一些事情并重新开始。
我有一个可以添加的想法,TAP Gesture recognizer但是我怎样才能popup在后台停止活动,然后在录制它之后做一些事情并重新启动Controller.
最好的祝福
要“弹出”图像,您只需创建一个以图像为背景的 UIButton 并将其隐藏 - 弹出您只需使其可见。
只需在按下按钮时连接到您喜欢调用的方法即可。
子类 UIView 以创建 PopupView 显示您需要的内容。重写此函数:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    [self setHidden:TRUE];
    [self removeFromSuperview];
}
我这里有一个取自 facebook 示例 iphone 代码的代码。它来回弹出一个带有动画的视图。
只需创建一个自定义按钮,链接它,在里面添加图像,调整框架/位置,然后隐藏它。
-(void) zoomInWorld{
    buttonImage.hidden = NO;
    buttonImage.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.001, 0.001);
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.2];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(bounce1AnimationStopped)];
    buttonImage.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1);
    [UIView commitAnimations];
}
- (void)bounce1AnimationStopped {
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.15];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(bounce2AnimationStopped)];
    buttonImage.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.9, 0.9);
    [UIView commitAnimations];
}
- (void)bounce2AnimationStopped {
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDuration:0.15];
    //[UIView setAnimationDidStopSelector:@selector(nextAction)];
    buttonImage.transform = CGAffineTransformIdentity;
    [UIView commitAnimations];
    [a addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlStateNormal];
}