0

I want a roll-up animation for the uiview. So i am animating a mainscrollview and a rollupboard. So in the viewDidLoad i set the frame of these two views as:

    dashRollUpStand=[[UIImageView alloc]initWithFrame:CGRectMake(0,346,320,0)];
    mainScrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(10,346,300,0)];

And i also have many subviews for this mainScrollView.

Now i am loading this view with a roll-up animation using the following code:

 [UIView beginAnimations:nil context:nil];
 [UIView setAnimationDuration:1];
 [UIView setAnimationCurve:UIAnimationCurveLinear];

 [dashRollUpStand setFrame:CGRectMake(0,0,320,346)];
 [mainScrollView setFrame:CGRectMake(10,9,300,337)];
 [UIView commitAnimations];

This rollup animation is working fine in iphone. But on iphone retina display this animation is not at all smooth. So how can i make it smooth in iphone retina display.

Priyanka V
  • 834
  • 2
  • 12
  • 34

2 Answers2

0

Is there a reason why you are adding your views in viewDidLoad and having them offscreen?

It seems to me that you should do it like this. In the code below containerView is the view that contains your views, toView is the view you are flipping to and fromView is the view you are flipping from.

[UIView transitionWithView:containerView
                  duration:1.0
                   options:UIViewAnimationOptionTransitionFlipFromRight
                animations:^{ 
                    [fromView removeFromSuperview]; 
                    [containerView addSubview:toView]; 
                }
                completion:NULL];

I also chose to use the block-based animation/transition API which is the recommended way since iOS 4.

EDIT:

Since you are not actually transitioning the view, even though your original code did. You could just use a normal animation block instead

[UIView animateWithDuration:1.0
                 animations:^{
                     [dashRollUpStand setFrame:CGRectMake(0,0,320,346)];
                     [mainScrollView setFrame:CGRectMake(10,9,300,337)];
                 }
                 completion:NULL];
David Rönnqvist
  • 56,267
  • 18
  • 167
  • 205
0

The problem is not the kind of animations you are using, but more probably what you have iside your views. First of all try to make sure that subviews inside your animated view are opaque, opaque is a property of UIView, but it is overridden if the alpha of the view is less that 1. The rendering system requires more clicles to blend clear views, if you can go for opaque.

Andrea
  • 26,120
  • 10
  • 85
  • 131
  • None of the subviews has alpha < 1. – Priyanka V Jun 08 '12 at 11:00
  • what about opaque property? are they set to yes? – Andrea Jun 08 '12 at 12:02
  • yes. i tried it after your suggestion. its not making any difference. – Priyanka V Jun 08 '12 at 12:37
  • The only way to understand is try using instruments, with time profiler or core animation (the last one to check FPS). Without any code is difficult to understand, but if do not find any solution one could be get an image of the current screen and animate this, removing all the subviews... – Andrea Jun 08 '12 at 12:42