Implement same page transition in UIDeviceOrientationLandscapeLeft and UIDeviceOrientationLandscapeRight - ios

I have developing project in iOS 6.0 sdk which should work on iOS4.3+ devices, in my project i am using the page curl to navigate betwwen pages , but the page curl happening in LandscapeLeft is not as same as Pagecurl in Landscape Right. I want the same page curl that is happening in Landscape Left to be in Landscape right.
Please take a look at the link for better understanding.
Video Demo Link
The code i have used is shown below
-(IBAction)nextBtnTapped {
UIDeviceOrientation deviceOrientation=[UIDevice currentDevice].orientation;
page2 *Obj=[[page2 alloc]init];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
if (deviceOrientation==UIDeviceOrientationLandscapeLeft)
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.navigationController.view cache:NO];
else if(deviceOrientation==UIDeviceOrientationLandscapeRight)
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.navigationController.view cache:NO];
[self.navigationController pushViewController:Obj animated:NO];
[UIView commitAnimations];
}
-(IBAction)prevBtnTapped {
UIDeviceOrientation deviceOrientation=[UIDevice currentDevice].orientation;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.8];
if (deviceOrientation==UIDeviceOrientationLandscapeLeft)
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.navigationController.view cache:NO];
else if(deviceOrientation==UIDeviceOrientationLandscapeRight)
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.navigationController.view cache:NO];
[self.navigationController popViewControllerAnimated:YES];
[UIView commitAnimations];
}
Can any one please tell me what wrong have i done in this code.
Any help will be appreciated.

UIDeviceOrientationLandscapeLeft with page curl is bugged. You won't get it to work correctly.

Related

iAd how to hide and show ads at a specifc point in my app

my goal is to have my iAd show at the main menu screen(which I already accomplished) but when the user push a button to start the game I want the ad to go away and when the game ends the ad to reappear...I saw a lot of other similar questions but none had answers(searched for hours :/ ). also checked the documentation and couldn't find a logical solution, I'm also a newbie,thanks!
*update the code im working with .h file
-(void) bannerViewDidLoadAd:(ADBannerView *)banner
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[banner setAlpha:1];
[UIView commitAnimations];
}
-(void) bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[banner setAlpha:0];
[UIView commitAnimations];
}

UIView transitionFromView change view heigh

I am using this code to change between 2 UIView:
UIViewAnimationOptions animationType = UIViewAnimationOptionTransitionFlipFromLeft;
[UIView transitionFromView:self.playlistTableView toView:self.playerView duration:0.5 options:animationType completion:^(BOOL finished){
[self.containerView sendSubviewToBack:self.upperView];
[self.containerView sendSubviewToBack:self.playerView];
self.isPlaylistVisible = !self.isPlaylistVisible;
isControlsHidden = NO;
}];
And i noticed a strange behavior, that when i made the flip the height of the self.playerView loosing 20px and after one second it's increase back to the normal frame size.
I try to change the animationType to UIViewAnimationOptionLayoutSubviews and now when i change between the view this behavior is not occur.
Any idea what can be the issue?
Please try this code.
[self.upperView setHidden:YES];
[self.playerView setHidden:NO];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:containerView cache:YES];
[UIView setAnimationDuration:1.0];
[UIView commitAnimations];
[containerView addSubview:self.playerView];
For getting reverse case
[self.upperView setHidden:NO];
[self.playerView setHidden:YES];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:containerView cache:YES];
[UIView setAnimationDuration:1.0];
[UIView commitAnimations];
[containerView addSubview:self.upperView];

Changing animation from view to view

I have a tabbar application with 4 tabs and a navigation bar hooked to one. On the tab with the navigation bar I have a button that brings you to a new page. I also have one that brings you back to the tab page, but I have a problem. When going back to the tab page the animation is going the wring way. I did this all with storyboards so no coding. I looked around and want to put this in the code:
- (void) pushController: (UIViewController*) controller
withTransition: (UIViewAnimationTransition) transition
{
[UIView beginAnimations:nil context:NULL];
[self pushViewController:controller animated:NO];
[UIView setAnimationDuration:.5];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationTransition:transition forView:self.view cache:YES];
[UIView commitAnimations];
}
But i have no idea how and where to put it in.
Take a look at this Apple guide to creating a custom segue. Your perform code would look something like this:
- (void)perform {
[UIView beginAnimations:nil context:NULL];
[self.sourceViewController.navigationController pushViewController:self.destinationViewController animated:NO];
[UIView setAnimationDuration:.5];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationTransition:transition forView:self.view cache:YES];
[UIView commitAnimations];
}
Then in your storyboard, set the type of the segue to Custom, and then enter the name of your custom segue class.

How to implement a page slide effect on iOS

I am creating an ePub reader, which reads ePub files. I want to implement a page slide effect similar to a physical book. For example.
What animation is this? This doesn't work:
- (void)loadPage{
[UIView beginAnimations:nil context:nil];
//change to set the time
[UIView setAnimationDuration:1];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
// do your view swapping here
[UIView commitAnimations];
}
on swipe:
- (void)swipeRightAction:(id)ignored
{
NSLog(#"Swipe Right");
if (_pageNumber>0) {
_pageNumber--;
[self loadPage];
}
}
- (void)swipeLeftAction:(id)ignored
{
NSLog(#"Swipe Left");
if ([self._ePubContent._spine count]-1>_pageNumber) {
_pageNumber++;
[self loadPage];
}
}
I have done the same with third party api. You can take refrence from below URL
https://github.com/jemmons/PageCurl
https://github.com/xissburg/XBPageCurl
https://github.com/brow/leaves

Can I "curl down" a page on popViewControllerAnimated?

I can "curl up" a view controller with this code:
[UIView beginAnimations:#"animation" context:nil];
[self.navigationController pushViewController:page animated:NO];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
but I can't curl down the last page like this:
[UIView beginAnimations:#"animation" context:nil];
[self.navigationController popViewControllerAnimated:NO];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
any idea why not? I just really want to "reverse" the animation (as if a sticker has been peeled off to show the 'push'ed view controller and stuck back on when they click a button).
Thanks
Ok, my old answer was totally wrong...
the problem is that you are popping the view controller before setting the transition view. If you change the code to this:
[UIView beginAnimations:#"animation" context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.navigationController.view cache:NO];
[self.navigationController popViewControllerAnimated:NO];
[UIView commitAnimations];
it works fine
Using OpenGL or a lot of complex CoreAnimation processes, I am sure that you could, but, It would be a lot of hassle for doing something like that. Something that might help you along: A simple book turning application written entirely with CoreAnimation

Resources