UIView animation in iphone retina display is not smooth - iphone

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.

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

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.

Related

UIView not displaying in landscape

I have a window with a UIView and a transition to another UIView. But when I do the transition, the window to transition to is displayed in portrait, and after the transition is finished, it goes to landscape.. But I want the UIView to be in landscape BEFORE the transition because otherwise the screen looks f*cked up because the background image is made for landscape mode. Here is my code:
UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:window cache:YES];
[[oldView view] removeFromSuperview];
[window addSubview:newView.view];
[UIView commitAnimations];
The orientation property of the newWindow is set to landscape in the interface builder, and also in the superview...
What am I doing wrong??
Thanks in advance!
First of all, you should not use multiple window, it will never give you the result you are expecting...
You can easily do the same thing with one window and 2 UIViews.
Solved... I had to put the commitAnimations part above the addSubview:newView
Hope this helps everyone with the same issue....

How can we turn views like turning a page in an iphone application?

Is it possible to turn a view slowly like turning a page? When i swipe from right to left, the current view will turn and the next view will be shown. And from left to right, the previous view will come slowly as we move the finger.
How can I do it? Any ideas??
You should add and remove subviews from your view by detecting the touch movements, using the animation transtion styles:
UIViewAnimationTransitionCurlUp //for removing views (vice-versa)
UIViewAnimationTransitionCurlDown // for adding views (vice-versa)
like:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:NO];
[self.view addSubview:nextView];
[UIView commitAnimations];
You should customize above according to ur needs.
Hope this helps.
Thanks,
Madhup

UIView Animation: Shrink

I'm looking to have my main view shrink to reveal the next view in the same way the Facebook app's views shrink when you press the top-left button. I already have it working with one of the included animations like this:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[self.navigationController popToRootViewControllerAnimated:YES];
[UIView commitAnimations];
However, since "Shrink" isn't one of the included animations, I'm a bit stuck. How could I make this shrink instead?
I'm fairly well-experienced with the iPhone SDK but haven't spent a lot of time with UIView animations.
Have you tried combining a scaling and translating transformation?
UIView's setAnimationTransition: method makes the packaged set of animations dirt simple, but if you want to do something else, you have to drop down a level and use Core Animation itself.
It isn't too bad: basically you use CATransaction's begin and commit methods and in between, get the view's layer and set its transform property directly. To shrink it you could set the scale to 0.00001, causing it to shrink.
Instead of removing the view right away, you will have to set a completion block and remove it yourself when the animation is done. And you might want to reset the transform back to normal, if you plan to use the view again.

Flipping UIView inside UIScrollView

In photo app of iphone you can see smooth scrolling to the other picture with finger flicking. Is it possible to allow individual view to be 'flipped' (or rotated) to show its back side ? Found that UIScrollView is used for smooth scrolling and found the code for flipping UI. Outside of UISCrollView I got the flip to work using the code below. But once inside UIScrollView this doesn't work - it executes but UI never switches.
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:myView cache:YES];
[UIView setAnimationDuration:1.0];
[myView exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
[UIView commitAnimations];
Perhaps this is not suppose to work this way. What is the recommended way or technique to have flippable individual views inside the UIScrollView ?
Never mind. It does work. Once inside UIScrollView there were several UIViews and I needed to make sure I grab the pointer to current UIView. The above code works in this case as well. I was doing a flip on a view which was hidden :)

Using of a single view to display different content on flip

I am trying to add a flip on row did select of every section.The flip side view should display the content of the selected section. I have tried to understand the apple transition tutorial but its tough to get.
Any simple application related to it .
Have you looked at the Apple Sample code? That is pretty well laid out and has a flip animation. If you create a default utility project, that code has pretty much nothing but flip code in it.
Generating a flip animation is very easy. You simply remove your main view (in your case the UITableView) and add your new view to the superView all inside a UIView animation block:
// start the animation block [UIView beginAnimations:nil context:NULL];
// Specify a flip transition
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];
[myAppsWindow removeSubView:myUITableView]; // obiously replace these views with the correct views from your app.
[myAppsWindow addSubview:mybackView]; // you should build this view with your details in it.
// commit the animations. The animations will run when this invocation of the runloop returns.
[UIView commitAnimations];