sbrady19 Posted April 14, 2009 Share Posted April 14, 2009 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 Link to comment Share on other sites More sharing options...
Combat Posted April 14, 2009 Share Posted April 14, 2009 Go and download all the iPhone example apps from developer.apple.com. There's one that shows how to do this. Link to comment Share on other sites More sharing options...
Poco Posted April 15, 2009 Share Posted April 15, 2009 You can use resignFirstResponder http://developer.apple.com/DOCUMENTATION/C...nFirstResponder [textField resignFirstResponder]; iPoco Link to comment Share on other sites More sharing options...
Klutsh Posted April 20, 2009 Share Posted April 20, 2009 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: 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 Link to comment Share on other sites More sharing options...
stroke Posted April 20, 2009 Share Posted April 20, 2009 You should really be using macros for stuff like that, not constants. Link to comment Share on other sites More sharing options...
Klutsh Posted April 20, 2009 Share Posted April 20, 2009 You should really be using macros for stuff like that, not constants. Would you mind providing an example? I'm just starting out too. Link to comment Share on other sites More sharing options...
andyong Posted April 27, 2010 Share Posted April 27, 2010 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]; } Link to comment Share on other sites More sharing options...
Recommended Posts