iPhone SDK page flip and Page curl - iphone

I got the page flips and curls to work. I'll describe what happens...
I build and Go
The App opens in simulator
I press a button and the page curls to page 2... but when it gets to page 2 the page drops down a bit. Why does this happen?

if you're using view controllers, you shouldn't be adding their views manually, but should be using -[UINavigationController pushViewController:animated:]. There are ways to use these two techniques together, but that might be more trouble than it's worth. I'd suggest not using a viewController for your second, curled in view, until you're a bit more comfortable with the UIXXXController design pattern. Just add an outlet in your primary viewController for the paged-in view and hook it up in IB.

- (IBAction)goToSecondView {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:[self view]cache:YES];
[self.view addSubview:secondViewController.view];
[UIView commitAnimations];
}

Related

iphone - wrong animations

I am building a book where I will use the page curl animation to flip the pages, something like this:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.45f];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:NO];
[UIView commitAnimations];
I will use curl down or up, according to the page being increased or decreased.
At some point the user can click on the chapter button and go a menu where he can choose the chapter. This menu is on a separate view, called using an animation like this
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:NO];
After the user chooses a chapter, I close the chapters choosing view using
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:NO];
and after this transition finishes, I call a method that will show the first page of the chosen chapter. This page will be shown using a page curl animation.
This is almost working fine, but this is the problem.
If I press the "choose a chapter" button again, instead of seeing a flip from right animation and see the "choose a chapter menu" I will see a page curl, that will review the same page I am already seeing and then, suddenly, the "choose a chapter menu" will appear, with no transition.
Is this something related to the animation being cached? Even if I declared the cache property as NO? How do I solve that?
thanks
Set some breakpoints. It sounds more like the "page curl" animation is being called spuriously.

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.

How do I make the modal view only come up half way?

So I have an app where you play a game, and at the end it asks you your name for recording of the high score. I would like to use a modal view to accomplish this, but I am experiencing some hiccups along the way. So far, all I have is the modal view sliding up all the way to the top of the screen, but there isn't anything there yet, it's just blank:
UINavigationController *navController = [UINavigationController new];
[self presentModalViewController:navController animated:YES];
I have seen on several other iPhone apps, the ability to make the modal view come only half way up the screen (or less) and then have a textfield where you can receive input, such as for my high score list. How would I go about restricing the size of the modal view? And perhaps adding a textfield onto it? Any help would be appreciated! Thanks
What makes you think presentModalViewController was used?
You can do this quite easily with an UIViewController and animation.
Using Animation, a sample would look like something like this:
//Move Screen UP:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[UIView setAnimationBeginsFromCurrentState:YES];
self.view.frame = CGRectMake(self.view.frame.origin.x, (self.view.frame.origin.y - kTextView_Keyboard_Offset), self.view.frame.size.width, self.view.frame.size.height);
[UIView commitAnimations];
Where the "kTextView_Keyboard_Offset is defined in my Contants. You would specify/replace with your Offset value equal the number of pixels in the direction that you would like to move.
Define a full-screen view with a transparent background - then put the obscuring content wherever you like.
Then you just bring it up as you would any other modal view.

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