Implement page curl when view contents are updated - ios

I have a set of worksheets that serially display i.e. as user completes one, the next one appears. In the code, the next worksheet is dynamically generating UIButtons/UILabels (and other subviews) to render it. I want to display this new worksheet with a page curl animation. Note that the view controller and the top level view remain the same, it's only the sub-views that are being re-created.
Can I use the UIViewAnimationTransitionCurlUp option to do this with my current approach? It seems like that is only to be used when one view is replaced with another.

Please try this. hope this will help u.
[UIView transitionWithView:self.view duration:0.3 options:UIViewAnimationOptionTransitionCurlUp animations: ^ {
[self.view addSubview:blurView];
} completion:nil];
here blurView will be your view.

Related

making the uipagecontrol animation look like uinavigationcontrol animation

I'm using the concept of the ui page control.
For example, I have multiple similar views. Let say 10 news articles. I put them in a a page control and am able to swipe between them.
However, I want to mimic the animation that the UINavController does. Is this possible? ie: not have the pages scroll end to end but instead a slight overlap and effect where one panel slides out at twice the speed of the one below it sliding in.
Any Ideas?
If i am not getting wrong understanding of your question..
As this is not possible to do with existing page controls you need your own logic
This is how it should be handled, you will need to adjustments as per your requirement..
Rough logic
[self.view addSubview:nextArticleView];
nextArticleView.frame = // set offscreen frame, in the direction you want it to appear from
//Set more time as newArticle should overlap to existing articles view
[UIView animateWithDuration:10.0
animations:^{
nextArticleView.frame = // desired end location (current articles initial frame)
}];
//set less time as current article should slide fast
[UIView animateWithDuration:5.0
animations:^{
self.view.frame = // desired end location (off screen)
}];

iOS Retractable Menu

I am currently developing an app that contains a music player. As of now it has a play, pause, & a select song button that shows the current song playing. Right now, the player is always on the screen. I want to make it so theres a button in the middle of the page so that when users click that, the whole media player with the play, pause, and select song button/icon will appear. When they click on that middle button again it shall hide those icons.
If anybody could point me in the right direction whether it be tutorials already out, or other discussions (I could not find any ones really) that would be awesome!
NOTE: I'm not trying to make the popover menu that facebook uses. This menu/audio player will expand/retract horizontally over the current view
Thank you in advance!!!!
Sounds like you need to look into the .hidden property of view objects (allows you to make views visible/not-visible), and possibly the ability to move views around on the screen with the .frame property (setting location, height/width).
Without some more detailed information about the effect you're trying to achieve, it's difficult to say more than that. If you use interface builder to set up the view/UI-objects you want to display, you can simply set the base view to hidden in interface builder and then when the user clicks your button set .hidden=NO for that view.
Note: to be able to show/hide everything as a unit like this, I'm assuming that you use a single UIView object in interface builder as the container (sized and placed where you want it) and then add your controller buttons as sub-objects inside that single view. This allows you to show/hide everything by just setting .hidden property for the containing view.
I'm not exactly sure what visual effect your looking for, but I think you already said it - just hide them.
You can do that a couple of ways.
One simple way is just to put those elements inside of their own view. Use a storyboard or xib file. Put your buttons and controls you want to hide show in a view.
Then create a reference in your view controller to that view. call it controlsView.
#property (strong,nonatomic) IBOutlet UIView *controlsView;
Make sure you connect that view.
Then when the button is pushed, just hide that entire view:
self.controlsView.hidden = YES;
When pushed again, show it:
self.controlsView.hidden = NO;
If you want a bit smoother look and feel, wrap it in an animation like this:
//to hide
[UIView animateWithDuration:2 animations:^{
[self.controlsView setAlpha:0];
} completion {
self.controlsView.hidden = YES;
}];
//to show
self.controlsView.alpha = 0;
self.controlsView.hidden = NO;
[UIView animateWithDuration:2 animations:^{
[self.controlsView setAlpha:1.0];
} completion {
}];
hope that helps

Why is part of my UIView covering the keyboard?

Part of my UIView is covering the iPad's keyboard.
The view you're seeing is simply a UIView I've added as a subview to my main view. When the keyboard is shown, I do shift the view up.
Has anyone ever seen this before?
EDIT
When the keyboard is shown, I move the view up:
[UIView animateWithDuration:SHOW_KEYBOARD_ANIMATION_DURATION animations:^{
CGRect frame = self.currentViewController.view.frame;
frame.origin.y -= SHOW_KEYBOARD_OFFSET;
self.currentViewController.view.frame = frame;
}];
EDIT
I use the follow code to add the view:
[UIView transitionFromView:fromView toView:toView duration:0.3f options:UIViewAnimationOptionTransitionCrossDissolve completion:nil];
Are you calling the code to move the view out of the way before or after the keyboard is displayed? In other words, are you registering for UIKeyboardWillShowNotification or UIKeyboardDidShowNotification?
I'm not sure where you are getting the keyboard size? Take a look at Apple's sample code again, see http://developer.apple.com/library/ios/#documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html, scroll down to the section on moving content that is located under the keyboard.
Where are you getting SHOW_KEYBOARD_OFFSET from? I bet that's the problem.
You should be catching the notifications, just as Kate said, and using the userInfo from them to work out what to do about moving your view around. Any hard coded values will break the second Apple change the keyboard size on you. In short, don't assume what the frameworks can so easily tell you.

Is there a full pagecurl? Updated

Ok, so I really like the pagecurl effect, only one problem, when sending feedback email from within the app, the partialPageCurl covers the cancel button and most of the send button for the mail. The buttons still work, but the users won't see them. Is there a way to get the partialPageCurl to a fullPageCurl where it's almost completely off screen? Thanks in advance! Here is currently how I'm pushing the view.
- (IBAction)HelpClicked{
MoreHelp *More = [[MoreHelp alloc] initWithNibName:nil bundle:nil];
More.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:More animated:YES];
[More release];
}
Check out the UICatalog code at apple's developer library. Here is the link:
http://developer.apple.com/library/ios/#samplecode/UICatalog/Introduction/Intro.html
When you run it you, select Transitions from the UITableView. See the action of 'Curl Image" button. If thats what you need...
You will find curlAction: method in TransitionViewController class. Basically it has two imageview inside a view. Based on which one is displayed and what was the previous transition (curl up or curl down), it displays the other image in a manner that it looks like you curl a page up and then curl it down. The curl imageview completely disappears. Im sure you can adapt it to your UI.
Its pretty much the same as PeyloW's answer only it uses the old setAnimation: commitAnimation pair.
No there is no full page curl variant for UIModalTransitionStyle.
If this is what you need then you must implement it manually yourself. It is more complex that doing a simple modal view controller but doable.
This code snipped only works in default portrait layout, and will need tweaking for your needs. But I hope it gives you an idea of what you need to do:
UIView* view = viewController.view;
view.frame = self.view.window.bounds;
[UIView transitionWithView:self.view.window
duration:0.2
options:UIViewAnimationOptionTransitionCurlUp
animations:^(void) {
[self.view.window addSubview:view];
}
completion:^(BOOL finished) {
[viewController.view removeFromSuperview];
[viewController presentModalViewController:viewController
animated:NO];
}];
PeyloW's and xs2bush's excellent suggestions will certainly give you a full page curl. I suspect that you're after a more-than-partial-and-less-than-full page curl though. I don't think there's an API for this, but how about a trick that might just work?
Use either PeyloW's or xs2bush's method, but also launch a timer with a duration slightly less than the UIViewAnimationOptionTransitionCurlUp animation duration.
When the timer expires, freeze the animation and remove it from the UIView that is curling up:
curledView.frame = [[curledView.layer presentationLayer] frame];
[curledView.layer removeAllAnimations];
Hopefully, this will get you the desired effect.
I'd use PeyloW's answer, but there is another way. Add a UIView to the modal view you are going to present (in viewDidLoad), and position it in the top left hand corner, and give it a backgroundColor of [UIColor clearColor]. That way the view will not be seen on screen, but the page curl transition will be forced to peel off the screen to 'show' the top-left hand corner view.

iOS UIView Transition, Container View Creation Issue

I've scoured blogs and Apple documentation and can't find an answer. Hope someone can lend their expertise.
I have a simple UIView animation that acts upon a container view 'gameContainer'. If I create this container view in a method called previously, all is well and good.
However, when I create 'gameContainer' immediately prior to the animation calls (code below) then the subView 'viewGrid' just appears without any animation effect.
-(IBAction) onInfoUp: (id) sender {
//Add a container UIView for animation
[self.view addSubview:gameContainer]; // Moving this line to 'viewDidLoad' cures problem
//Call animation methods
[UIView beginAnimations:#"newGrid" context:nil];
[UIView setAnimationDuration:1.3];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:gameContainer cache:YES];
[gameContainer addSubview:viewGrid];
[UIView commitAnimations];
}
I'm stumped as to why I must define the subview container in a separate method! Thanks in advance.
I believe this is due how UIKit updates the visual contents on the screen. All actual modifications to the screen happens at the end of the current run loop if it's running on the main thread, or at the end of the next run loop on the main thread otherwise. If you add gameContainer as shown in the code, it's not on the representation layer for the screen.

Resources