Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 04-18-2011, 05:51 AM   #1 (permalink)
Registered Member
 
sacha1996's Avatar
 
Join Date: Mar 2011
Posts: 415
sacha1996 is on a distinguished road
Default Animation

Hi,
I have an UIImageView called myImage.
I've implemented the code in an button the make the frame +100 height and width...
So when I press the button it's being bigger.
Code :
Code:
-(IBAction)pushButton {
	
    CGRect newFrame = myImage.frame;
    newFrame.size.width = myImage.frame.size.width+100;
    newFrame.size.height= myImage.frame.size.height+100;
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.9];
    [myImage setFrame:newFrame];
    [UIView commitAnimations];
    [UIView setAnimationDelegate:self];
}
All is working fine , but I want to add some code I don't know.
1 - I want to hide the imageview tilll the user press the button. So no image , user press , image comes with an animation of +100 for the frame size.

2 - After 0.9 second I want the animation stops and hide itself as the before pressing the button.

Can anyone please help me ?

Thankyou
sacha1996 is offline   Reply With Quote
Old 04-18-2011, 07:56 AM   #2 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

you can use .hidden property to hide your image and a NSSTimer to fire an event after x seconds.
__________________
dany_dev is offline   Reply With Quote
Old 04-18-2011, 08:10 AM   #3 (permalink)
Registered Member
 
Join Date: Sep 2010
Location: KSA
Posts: 109
aziz is on a distinguished road
Send a message via MSN to aziz Send a message via Yahoo to aziz Send a message via Skype™ to aziz
Default

Code:
// Delay execution of my block for 0.9 seconds.
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.9 * NSEC_PER_SEC), dispatch_get_current_queue(), ^{
		myButton.hidden=YES;
	});
aziz is offline   Reply With Quote
Old 04-18-2011, 08:12 AM   #4 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 75
matt62king is on a distinguished road
Default

Use the the UIView animation blocks and you can set an action to be called when the animation is completed.
__________________
My Twitter -- @matt62king
matt62king is offline   Reply With Quote
Old 04-18-2011, 08:17 AM   #5 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 864
nobre84 is on a distinguished road
Default

on viewDidLoad set myImage.hidden = YES;
on pushButton, you set myImage.hidden = NO, then your animation.
Then you add this along with your animation :
Code:
-(IBAction)pushButton {
	
    CGRect newFrame = myImage.frame;
    newFrame.size.width = myImage.frame.size.width+100;
    newFrame.size.height= myImage.frame.size.height+100;
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.9];
    // set yourself as the animation delegate
    [UIView setAnimationDelegate:self];
    // tell the animation block what method to call when it finishes
    [UIView setAnimationDidStopSelector:@selector(hideImage)];
    [myImage setFrame:newFrame];
    [UIView commitAnimations];
}

//this will be called after your animation ends.
-(void)hideImage {
  myImage.hidden = YES;
}

Last edited by nobre84; 04-18-2011 at 08:20 AM.
nobre84 is offline   Reply With Quote
Old 04-18-2011, 10:57 AM   #6 (permalink)
Registered Member
 
sacha1996's Avatar
 
Join Date: Mar 2011
Posts: 415
sacha1996 is on a distinguished road
Default

Quote:
Originally Posted by nobre84 View Post
on viewDidLoad set myImage.hidden = YES;
on pushButton, you set myImage.hidden = NO, then your animation.
Then you add this along with your animation :
Code:
-(IBAction)pushButton {
	
    CGRect newFrame = myImage.frame;
    newFrame.size.width = myImage.frame.size.width+100;
    newFrame.size.height= myImage.frame.size.height+100;
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.9];
    // set yourself as the animation delegate
    [UIView setAnimationDelegate:self];
    // tell the animation block what method to call when it finishes
    [UIView setAnimationDidStopSelector:@selector(hideImage)];
    [myImage setFrame:newFrame];
    [UIView commitAnimations];
}

//this will be called after your animation ends.
-(void)hideImage {
  myImage.hidden = YES;
}

Thanks everyone !
nobre84 : your code imazing , but I have still one thing to add to it if available.
The imageview is from 0 to 100 after the button push (frame +100) , but when i press again it stills goes from 100 to 200 , but I want after the animation the frame size resets so after second push it will be the same as the first one.
So first push from 0 to 100
Second push from 0 to 100
Third push from 0 to 100 and for all the pushes like this.
What's the code for that ?

Thankyou
sacha1996 is offline   Reply With Quote
Old 04-18-2011, 12:45 PM   #7 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 864
nobre84 is on a distinguished road
Default

Just reset the frame to the desired value when you hide it
nobre84 is offline   Reply With Quote
Reply

Bookmarks

Tags
animation, core, sdk

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 356
14 members and 342 guests
dansparrow, dre, ilmman, LezB44, lorrettaui53, Nobbsy, Objective Zero, oztemel, pbart, samdanielblr, shagor012, sledzeppelin, thephotographer, Trickphotostudios
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,119
Posts: 402,896
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:47 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0