I have an idea for an iphone app. I am pretty good with Applescript and Xcode. iPhone is totally GREEK to me. I have many questions but will ask them one at a time until I get the 1st one answered.
Qu 1 is very basic.
1. I am using the iPhone Utility template, so there is an "i" you click to flip the screen. My interface has text boxes. OK you know what is coming next...............remember to be super specific in your explanation.
HOW DO YOU GET THE KEYBOARD TO GO AWAY AFTER YOU ENTER YOUR TEXT.
shawn
6 replies to this topic
#1
Posted 14 April 2009 - 04:11 PM
#2
Posted 14 April 2009 - 10:22 PM
Go and download all the iPhone example apps from developer.apple.com. There's one that shows how to do this.
#3
Posted 15 April 2009 - 08:57 PM
[textField resignFirstResponder];
iPoco
#4
Posted 20 April 2009 - 02:23 PM
If you have ever used a UITextField on the iPhone and seen the screen ’slide’ up to keep the UITextField in view, well here is how I’ve done it.
(This is for Portrait orientation only)
In your “ViewController.h” place 2 constants:
Then in your “ViewController.m” place 2 voids:
Then in interface builder set each UITextField’s delegate to “File’s Owner”.
The textFieldShouldReturn make the keyboard close, the other handles shifting 'up' to display to keep the textfield in view while your typing
(This is for Portrait orientation only)
In your “ViewController.h” place 2 constants:
static const CGFloat FKEYBOARD_ANIMATION_DURATION = 0.3; static const CGFloat FPORTRAIT_KEYBOARD_HEIGHT = 216;
Then in your “ViewController.m” place 2 voids:
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
CGRect textFieldRect = [self.view.window convertRect:textField.bounds fromView:textField];
animatedDistance = floor(textFieldRect.origin.y - FPORTRAIT_KEYBOARD_HEIGHT);
if( animatedDistance > 0){
CGRect viewFrame = self.view.frame;
viewFrame.origin.y -= animatedDistance;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:FKEYBOARD_ANIMATION_DURATION];
[self.view setFrame:viewFrame];
}else{
animatedDistance = 0;
}
[UIView commitAnimations];
}
and
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
Then in interface builder set each UITextField’s delegate to “File’s Owner”.
The textFieldShouldReturn make the keyboard close, the other handles shifting 'up' to display to keep the textfield in view while your typing
#5
Posted 20 April 2009 - 07:00 PM
You should really be using macros for stuff like that, not constants.
#6
Posted 20 April 2009 - 11:24 PM
#7
Posted 27 April 2010 - 02:56 PM
I created an action called backgroundTap that resigns firstresponder to my UITextFields. Then connected it up to the view. So once you've finished entering numbers via the number pad you can tap anywhere else on the screen, or in another control and the number pad disappears. For the keyboard you can do the same kind of thing when you click the done button.
-(IBAction)backgroundTap:(id)sender {
[peopleCount resignFirstResponder];
[billTotal resignFirstResponder];
}
-(IBAction)backgroundTap:(id)sender {
[peopleCount resignFirstResponder];
[billTotal resignFirstResponder];
}
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users



Sign In
Create Account









