How do I create a page flip effect programmatically? - iphone

I'm pretty sure I can create a page flip effect using a series of PNGs to simulate the animation but is there a way to do it programmatically? Tried googling it and looking at Apple sample code but didn't see anything addressing that particular animation.

I'm assuming you mean for an iPhone, right?
From the Apple API docs for UIView:
+ (void)setAnimationTransition:(UIViewAnimationTransition)transition forView:(UIView *)view cache:(BOOL)cache
where UIViewAnimationTransition is defined as:
typedef enum {
UIViewAnimationTransitionNone,
UIViewAnimationTransitionFlipFromLeft,
UIViewAnimationTransitionFlipFromRight
UIViewAnimationTransitionCurlUp,
UIViewAnimationTransitionCurlDown,
} UIViewAnimationTransition;
UIViewAnimationTransitionCurlUp is what you are looking for. See those docs for information on how to start, set, and commit animations to views as well.

Related

Scroll tableview cell in cube effect in iOS?

Writing up an code for creating table view in such a manner when user scroll table view it behaves like cube. Please find below youtube link for the vision what I am asking for:
http://www.youtube.com/watch?v=hrBxHq83yKQ
Meanwhile, I tried with CATransform3D transform = CATransform3DMakeRotation(angle, 1, 0, 0); and it working for adding up an row at the top but not for scrolling.
Further, due to lack of knowledge of OpenGLES I can not go with it for rotating the cubes with touch gesture. Please suggest for the same as per your feasibility.
Look forward to hear from you.
check it out.. hope it helps you..
Link 1: https://www.cocoacontrols.com/controls/abcustomuinavigationcontroller
Link 2: https://github.com/augustjoki/CubeTabBarController
you can achieve this effects with Layer transform and a scrollview. To build a cube take a look at this post. You might add some overlays to your cube-sides to simulate lightning and you are done.
I got an answer for cubical scrolling. Earlier I was using below source code link:
GestureBasedTableViewDemo
Meanwhile, above tableview demo was using gesture and allow me to only add first row in tableview cell while scrolling down but my requirement was to have cubical scrolling up or down both.
Further, I tried with vertical iCarousel cylindrical and I achieved the vertical cubical scrolling. Thanks
You might also want to check our implementation of a gesture based 3D-cube over at Chubamobile:
http://www.chupamobile.com/products/details/2106/Cube+Selector/
It's fully featured, ready to use out of the box - and pretty much exactly what you want
Maybe it helps.
CATransition *animation = [CATransition animation];
animation.duration = 1;
animation.type = #"cube";
animation.subtype = #"fromRight";
[self.contentView.layer addAnimation:animation forKey:#"animation"];
[self.contentView bringSubviewToFront:view];
or that link http://www.albertopasca.it/whiletrue/objectivec-3d-view-rotation/
Don't dislike - there are few information about it.

How to make half curl animation in iPhone like the maps app?

I am using the following code for page curl animation
[UIView beginAnimations:#"yourAnim" context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:yourView cache:cacheFlag];
...
[UIView commitAnimations];
Is it possible to make the half curl animation like the maps.app on iphone/ipod ?
Any ideas how to make an similar effect ?
Thanks
Apple does support this for the presentation of modal views as of 3.2. This makes sense: the page curl effect is intended to signal the user that a page of options or settings is being revealed, and when they are done changing things, they will be sent back to the original view. Apple doesn't want the animation to infer an ongoing change to the page hierarchy, just a modal one that must return to its starting place.
It's pretty straightforward to use; just be sure that you are starting from a full screen view, and loading with the UIModalPresentationFullScreen style, which I believe is the default.
There are animation transitions to use a similar effect in UIViews generally that were added as of 4.0, but this is a straightforward way to use the effect.
simpleVC * myModalVC = [[simpleVC alloc] init];
[myModalVC setModalTransitionStyle:UIModalTransitionStylePartialCurl];
[myModalVC setDelegate:self];
[self presentModalViewController:myModalVC animated:YES];
[simpleVC release];
Link to Apple Docs on UIModalTransitionStyle constants
I too have been working on this issue and I settled in the short term on a PNG version of it placed within a button and using the curl to reveal animation. The only thing missing in my solution is the ability to interact (play) with the curling page the way you can in Maps.
The Method
First, I created a Page corner PNG in Photoshop based on a screenshot of Maps.
The Map Curl PNG
The Map - Options Hidden
The Map - Options Revealed
Then, I added it to a UIButton that does a partial page curl transition.
Complete Source Code Available on GitHub
The complete working project is available at GitHub. Updated for iPhone 5.
Use the undocumented animation types mapCurl and mapUnCurl

How do I make a side-scrolling iPhone app?

I am working on a side-scrolling iPhone app, and I have every resource, except the actual side scrolling part! How do I make an app so that it side-scrolls? To be more specific, I want the view of the app to scroll when a UIImageview(player) hits the right/left border of the screen.
<:EDIT:>
I am extremely sorry for all of this confusion! All I am making is a SAMPLE iPhone app only to be used in the simulator. In the app, I have a UIImaageview that moves when you touch arrow UIImageviews. PLEASE NOTE THAT ALL INFORMATION SAID BEFORE THIS SENTENCE WORKS PERFECTLY! Now, my problem is that I want the UIView to scroll only ONE picture(this means it doesn't go forever ;)). I have tried using a UIScrollView, but that didn't work. Finally, I am not planning to use Cocos2D or any other game engine besides a basic UIview. This is only a test app, not a coding extravaganza...
If you're writing a game, you may benefit from a lot of the features given to you by engines such as Cocos2D.
Start with a view-based application template so you can get the gist of how this works. Later you can integrate with your existing code.
Create a seamless background image 320 x 960 pixels, named "seamless.png"
Add this ivar to your view controller .h file
UIImageView *bg;
#property (nonatomic, retain) UIImageView *bg;
In your .m file add these #defines before the #implementation line, the #synthesize after.
#define kUpdateRate (1.0 / 60.0)
#define kMoveY (3.0)
#define kTopY (0.0)
#define kBottomY (480.0)
#synthesize bg;
Add this method.
-(void)scrollView; {
float oldY = self.bg.center.y + kMoveY;
float newY = oldY;
if (oldY > kBottomY) {
newY = kTopY;
}
self.bg.center = CGPointMake(self.bg.center.x, newY);
}
Add this to your viewDidLoad method.
self.bg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"endless.png"]];
[self.view addSubview:self.bg];
self.bg.center = CGPointMake(self.bg.center.x, kTopY);
[NSTimer scheduledTimerWithTimeInterval:kUpdateRate target:self selector:#selector(scrollView) userInfo:nil repeats:YES];
When you run the app, you should have a nice scrolling background.
To sum up what happens: A timer is set up to repeatedly call scrollView:
There, the image is moved downwards until it reaches a predefined point (kBottomY), at which time its position is jumped back up to the top (kTopY) and it starts over again.
You can customize it to only scroll when you want it to or scroll the other way on your own, right?
If the image being side-scrolled is large, I'd suggest scrolled view while taking advantage of CATiledLayer. See the WWDC10 Session 104 video and the "Tiling" sample code.
BTW, there is nothing in the Apple docs that seem to prejudge the use of scroll views for utility or menus.
Are you trying to use a UIScrollView? If so, just set your scrollView's content size to something wider than the screen. For example:
self.scrollView.contentSize = CGSizeMake(640, 480);
You should use a UIScollView (http://www.iphonedevsdk.com/forum/iphone-sdk-tutorials/3393-uiscrollview-tutorial.html). Or am I missing the point?
Just make the main view wider than the screen and change the bounds accordingly to show a different portion of the main view. This assumes your main view does have some kind of a limited width. It's slightly trickier if that view just goes forever. In that case you change the bounds and draw the newly revealed content.
If this doesn't make sense then I think you need to reword your question or do some experimentation to narrow down what you're asking.
Take a look at Cocos2D for the iPhone which also includes a choice of 2 collision engines, chipmunk and box2d
I can also recommend the oreilly book iPhone game development, which if you are new to game development will teach you how to roll a basic game framework

How to code zooming and panning for a UIImageView?

I have a UIImageView object, attached to a controller. It displays fine. What is a easy way to get zooming and panning with the least amount of code? Perhaps some library out there that does this? Hard to believe the SDK does not provide anything.
Add your UIImageView as a subview of a UIScrollView and make sure you change the minimumZoomScale or maximumZoomScale.
Also take a look at the documentation for UIScrollView there might be other settings you want to tweak.
UIScrollView is the SDK class you're looking for
The Three20 project has a photo viewer you may want to look into, that I believe supports zooming and panning in a larger image.
try using
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
}
Here is some code
http://www.redcodelabs.com/2009/09/objective-c-zoom-image/

Two related questions about iPhone autorotation

1) Is it possible to change the speed of autorotation on the iPhone?
2) Is it possible to time an animation to take place during the autorotation animation? I would like to resize a photo while rotation is occuring, rather than when it's done.
1) not that I know of
2) Yes, see this method:
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
http://developer.apple.com/iPhone/library/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006926-CH3-SW53
As for the first question, I haven't used this but check it out:
[UIApplication sharedApplication].statusBarOrientationAnimationDuration = [NSTimeInterval ...];
See docs for UIApplication. The problem is that I don't know that this actually rotates the rest of your views. You may, however, be able to rotate the window's coordinate system around "manually" using UIWindow and [UIView beginAnimations ...] in order to recreate the whole effect.
Please post sample code somewhere if you get it working!