Grettings to you...
i want to paginate when the user swipe on the left or right side of the uiview
i am able to detect the swipes using UISwipeGestureRecognizer.
now what i am trying to do is when the user is swiping i want to give slide animation.
currently i have the below code
[UIView beginAnimations:nil context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft, forView:[self cardView] cache:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.5];
this gives me the flip effect when i swipe on the view.
Please provide me some example or links to try the slide effect when swipe on the view.
Many Thanks!
You're going to want to use a UIScrollView, not a straight UIView. This has support for swipes and paging. Here's a nice tutorial to get you started. Good luck!
Related
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 trying to animate a UIView so that it can grow larger when tapping a button and shrinks down to its original size by tapping the button again.
I do this by adjusting frame to its new size and origin and running the code below.
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
self.theView.frame = frame;
[UIView commitAnimations];
When animating to a bigger size the animation is how it should be. But when animating to its original size (smaller) the view is re-sized instantly and then animated to its designated location.
What I need is that the resizing to the smaller frame is animated as well.
I've tried adjusting the autoresizingMask as well, but that didn't change anything.
Hope someone can help.
thanks.
Michiel, Raj,
I made a youtube tutorial showing how to make views expand and shrink like in the facebook iPhone app.
Hope it can be of some help: How to make expanding/shrinking views on iPhone SDK
Adam
Try this
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationRepeatAutoreverses:YES];
self.theView.frame = frame;
[UIView commitAnimations];
In response to comment;
If you want to control animation reverse, have a flag like BOOL isbig and set it in app launch to NO, then toggle it in every button tap, then check it if it is YES or NO, and according to the result call a method. If NO, call your code, if not call the code again but this time set the frame to the original size.
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
self.theView.frame = originalFrame;
[UIView commitAnimations];
I could solve the problem by suggestion found in other thread, it has its own limitations though. I have posted the code in the same thread where the solution was suggested:
UIView scaling during animation
I worked around this problem when releasing my app by just removing the animation.
It kept bugging me in the back of my mind, so just this week I thought that maybe by using the center property and the size instead of the origin it would make a difference.
So I decided to test this out. Guess what. The problem doesn't occur when using sdk 4.x
Thanks all for trying to help me out.
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 :)
Is there any way to animate leafing through views to look like a real book leafing through?
There is always the option of using CoreAnimation to animate any view. For this purpose, it could become quite complex though.
There is a native animation for UIView that peels it up from the corner like a page. This kind of animation is more akin to leafing through a notepad than a book but it may just serve the purpose your looking for. If you wanted to do this it would look something like this:
[UIView setAnimationDuration:duration];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:view cache:NO];
[UIView commitAnimations];
The duration of the animation can be set to whatever you like.
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];