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];
Related
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.
I have a project that includes a table that is dynamically created and formatted without using IB. The issue is, that the table needs to change both values and size during a rotation. However, the resizing is choppy and occurs suddenly during the animation. Currently I'm using the didRotate method, and in that method I'm calling the reload method in order to resize it. Should I be using a different method to do this, or is there anyway to at least smooth out the resizing?
Edit: I'm trying to use the replacement/resizing within the willRotateToInterfaceOrientation:, or possibly the two step animation. However, these methods are never called, is this due to the view hierarchy (the view I'm trying to resize is part of a split view)?
Do you tell the didRotate method to use animation when making the changes? For example, here is a code snippet that makes a flip transition. The key is to use the "beginAnimations" and "commitAnimations" to tell the iPhone how to handle those changes. The code in between describes the changes. When the "commitAnimations" is called, the changes are magically animated.
[UIView beginAnimations:#"leftPortrait" context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:1.0f];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:leftView cache:YES];
[leftWebView setFrame:CGRectMake(0, 0, 384, 916)];
[UIView commitAnimations];
Hope this helps.
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
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.
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 :)