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 05-24-2011, 02:29 PM   #1 (permalink)
learner2011
 
Join Date: Mar 2011
Posts: 115
ashwinr87 is on a distinguished road
Default Animation a UIButton while animating a View - Ipad

Hi,

I am facing a problem in animation.

So right now in my app, I have a subview which has a close button. When the close button is pressed, a curl down animation occurs showing the previous view. That is working properly. I perform the curl down closing animation by passing a notification to the NSNotificationCenter like this
Code:
[[NSNotificationCenter defaultCenter] postNotificationName:notificationName object:self];
Now I wanted to apply an animation to the close button itself so that when I press the close button, it would perform an animation as well as the curl down animation would occur. So the way I do it is by the following code

Code:
[UIView transitionWithView:self.view.superview duration:1  
                          options:UIViewAnimationOptionCurveEaseIn  
animations:^ { closeButton.frame = CGRectMake(500, 15, 100, 40); }  
                  completion:nil];
Where previously the closeButton.frame had the value of (580,15,100,40) so the animation would be like the image was moving from right to left from 580 to 500.

So what happens when I run the code is that when I press the close button, the close button animation does not happen but the curl down animation occurs. So for testing when I commented out the code where I post the notification, the close button animation works perfectly but the curl down animation does not happen nor does the previous view come up ( since I do not send a notification which would cause the view to close).

I would like to know what is going wrong here and why it does not allow 2 animations to occur at the same time.
ashwinr87 is offline   Reply With Quote
Old 05-24-2011, 03:23 PM   #2 (permalink)
Registered Member
 
Join Date: Jan 2011
Posts: 144
iAppDev is on a distinguished road
Default

use this. much easier
Code:
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationCurve: UIViewAnimationCurveEaseIn];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationBeginsFromCurrentState:YES];
    bonusPoints.transform = CGAffineTransformMakeScale(1.0, 1.0);
    [UIView commitAnimations];
iAppDev is offline   Reply With Quote
Old 05-24-2011, 04:49 PM   #3 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

I advice you to use block style, since that apple advice us to do it

i'm not sure that will solve, but try that
Code:
[UIView transitionWithView:closeButton.superView duration:1  
                          options:UIViewAnimationOptionCurveEaseIn  
animations:^ { closeButton.frame = CGRectMake(500, 15, 100, 40); }  
                  completion:nil];
__________________
dany_dev is offline   Reply With Quote
Old 05-25-2011, 09:57 AM   #4 (permalink)
learner2011
 
Join Date: Mar 2011
Posts: 115
ashwinr87 is on a distinguished road
Default

Here is how I solved it...

I used the nested animation using blocks where I included the code for the curl down close view in the completion part of the close button animation...

Code:
[UIView transitionWithView:self.view.superview duration:1
                       options:UIViewAnimationOptionCurveEaseIn
                    animations:^ {
                        popContents.closeButton.frame = CGRectMake(500, 15, 100, 40); }
                    completion:^(BOOL finished){
                        [UIView transitionWithView:self.view.superview duration:1
                                           options:UIViewAnimationOptionTransitionCurlDown
                                        animations:^ {
                                            popContents = nil;
                                            [popContents.view removeFromSuperview];
                                            [ovController.view removeFromSuperview];
                                            ovController = nil; }
                                        completion:nil];
                    }];
ashwinr87 is offline   Reply With Quote
Old 05-25-2011, 09:59 AM   #5 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

oh, initially i though that you want to run the 2 animation togheter, not one after the other...

however nice work...
__________________
dany_dev is offline   Reply With Quote
Reply

Bookmarks

Tags
ios, ipad, nsnotificationcenter, uianimation, uiview

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: 361
7 members and 354 guests
doffing81, dre, iOS.Lover, jenniead38, Kirkout, PlutoPrime, Wikiboo
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,120
Posts: 402,898
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 02:08 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0