Keyboard appearing without animation on iOS 5 - iphone

I have a popup view which I animate in the current view from the bottom using MJPopupViewController and there is a UITextField in that popup view. When I tap on that textfield, instead of animating from the bottom, the keyboard appears immediately. the popup view is a UIViewController and there is nothing fancy in it, no code related to the keyboard. i added observers to related keyboard notifications and saw that the UIKeyboardAnimationDurationUserInfoKey value is 0 even though it is the first time the keyboard is displayed in the app. the keyboard disappears with animation properly, only the animation of keyboard sliding in from bottom is broken. this occurs on iOS 5.0 and 5.1, the keyboard functions properly on iOS 6 +. i'm trying to track down the issue but right now i am out of clues. what causes UIKeyboardAnimationDurationUserInfoKey to be zero, for a start?

Try adding this.
-(void)textFieldDidBeginEditing:(UITextField *)textField
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.view cache:YES];
[textField becomeFirstResponder];
[UIView commitAnimations];
}
PS: We need to set the delegate for this one.

Related

Effect like deletion in ios

I need hint/code like deletion/move app effect on iOS, normally i have started the code, I am using UIButton list in UIScroll.
So my question is that supposes I have 8 to 10 button in screen and i want to change their position with dragging. for example choose 6th button and move or set to between 1 and 2. when I put them in to between the position of other button will change.
I am using UIPanGestureRecognizer for dragging.
download, Tiles-v1.0.zip, and check code, this is what i used when i needed to implement that.
reference: Move UIViews to avoid collision like rearranging icons on Springboard
If you already have the code for dragging, the rest is easy. Just use UIView Animation.
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3];
...
[button setFrame:newFrame];
...
[UIView commitAnimations];
Basically, just move your buttons to the their new positions in that beginAnimations - commitAnimations block.
Hope this helps.

How to make the textfield move up when keyboard covers it up

I have an application in which I have 2 textfields and a textview. When I click on the first textfield my keyboard popsup and theirs is no problem but when I type in the second textfield my keyboard popsup and covers the textfield.
I want that when I click on the second text field, the textfield should move up little bit so that I can type in and I have a textview. But I have written code for textview so that when I type in textview it automatically moves.
The problem is with textfield. How can I solve this problem?
Consider using a UITableViewController. Otherwise implement UITextFieldDelegate and move your UIView to the desired position in the - (void)textFieldDidBeginEditing:(UITextField *)textField method.
Check out the link below - the solution is written by Micheal Tyson. It addresses UITableView and UIScrollView, can be easily changed and works just as a drop-in component. I'm using it and it works well.
A drop-in universal solution for moving text fields out of the way of the keyboard
Create two methods like given below , first one is for bringing the view slightly upwards, and second one is to bring the view to its original position back
First method:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:.3];
self.view.transform = CGAffineTransformTranslate(self.view.transform, 0, -175);
[UIView commitAnimations];
Second method:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:.3];
self.view.transform = CGAffineTransformTranslate(self.view.transform, 0, 175);
[UIView commitAnimations];
[self.destext resignFirstResponder];
Call these methods on textfieldEditingDidbegin and DidEndonExit
Add the view to a UIScrollView. Then use the UITextFieldDelegate methods to set the contentOffset of the scrollView when textField is tapped. Reset the contentOffset when the user has finished entering text.
I have created a simple subclass of UIView containing UITextView and a send button that moves up when keyboard shows and moves down when keyboard hides. In addition to that, UITextView resizes according to the amount of text in it.
Have a look at here:
https://github.com/kerrygrover/KBTextView
An obvious one that you've probably tried already, but one that took me a while to latch onto, is to change from landscape to portrait.

How can we turn views like turning a page in an iphone application?

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

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.

iPhone SDK page flip and Page curl

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