Muhammad Umar
Muhammad Umar

Reputation: 11782

make a popup image in iphone

I am working on a small game in which if you win it will show you an image. The image size is of full screen. I want to make it as when i tap on it , it removes and activity or viewController do some stuff and starts again.

I have an idea that I can add TAP Gesture recognizer but How can I popup an Image that stops the activity in the background and then after taping it do some stuff and restarts the Controller.

Best Regards

Upvotes: 0

Views: 1233

Answers (3)

HelmiB
HelmiB

Reputation: 12333

I have a code here taken from facebook example iphone code. it pops a view with animation back-and-forth.

just create a custom button, link it, add image inside, adjust frame/position, and hidden it.

-(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];

}

Upvotes: 0

WolfLink
WolfLink

Reputation: 3317

Subclass UIView to create PopupView that displays what you need it to. Override this function:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    [self setHidden:TRUE];
    [self removeFromSuperview];
}

Upvotes: 0

user387184
user387184

Reputation: 11053

To "popup" an image you could just create a UIButton with the image as its background and have it hidden - to pop up you just make it visible.

Just connect to the button the method you like to be call when the button is pressed.

Upvotes: 1

Related Questions