Finger twist
Finger twist

Reputation: 3786

View not animating

I'm using this method to try to move my view up but without success, this is the code in my MainViewController implementation file :

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];

CGRect rect = self.view.frame;
if (movedUp)
{
    NSLog(@"should move Up");
    rect.origin.y -= 50;
    rect.size.height += 300;
}
self.view.frame = rect ;

[UIView commitAnimations];

It is not erroring out and it's printing out "should move Up" so I know that the method is executed properly .

This is the IB hierarchy ( I`m trying to move the highlighted View) :

alt text

Any help would be greatly appreciated, I`m running out of ideas ..


Ok, Editing here I've isolated the problem to be something else, I'm using this code now :

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:.5];

self.containerView.frame = CGRectMake(0, 0, 250, 50);

[UIView commitAnimations];

and if I injecting this code in "- (void)viewDidLoad" it's working fine .

but if I use the same code in a different function in the same ViewController implementation file , it's not working :

- (void)setViewMovedUp:(BOOL)movedUp {


        NSLog(@"test movedUp");
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:.5];

        self.containerView.frame = CGRectMake(0, 0, 250, 50);

        [UIView commitAnimations];



}

BUT it's still printing out "test moved up" so the code is executed, just the view not animating .

Upvotes: 0

Views: 150

Answers (3)

Ashish Mathur
Ashish Mathur

Reputation: 82

use

[self.view setFrame:rect];

instead of

self.view.frame = rect ;

I think the animation will not be used for self.view.

Upvotes: 0

Vinod ram
Vinod ram

Reputation: 95

go through this link using the tableview as horizontal scroll and animating the views and also animating the text like marquee check in the method -(void)handleSwipeGesture:(UISwipeGestureRecognizer *) sender

Upvotes: 2

Michael Kessler
Michael Kessler

Reputation: 14235

Try moving another view - not the main one.
Maybe there is a problem moving the main view.

If it works then add one more view to your views hierarchy that will contain all the others and connect it to a IBOutlet.

If it doesn't work then comment me and we'll try to figure it out...

Upvotes: 1

Related Questions