Jump to content

fluid | fixed

need iphone dev help


  • Please log in to reply
6 replies to this topic

#1
sbrady19

sbrady19

    InsanelyMac Protégé

  • Just Joined
  • Pip
  • 1 posts
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

#2
Combat

Combat

    InsanelyMac Protégé

  • Members
  • Pip
  • 30 posts
Go and download all the iPhone example apps from developer.apple.com. There's one that shows how to do this.

#3
iPoco

iPoco

    InsanelyMac Legend

  • Supervisors
  • 1,341 posts
  • Gender:Male
  • Location:Canada
You can use resignFirstResponder http://developer.app...nFirstResponder

[textField resignFirstResponder];


iPoco

#4
Klutsh

Klutsh

    InsanelyMac Protégé

  • Members
  • Pip
  • 30 posts
  • Gender:Male
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

#5
stroke

stroke

    InsanelyMac Sage

  • Members
  • PipPipPipPipPip
  • 350 posts
  • Location:Russia
You should really be using macros for stuff like that, not constants.

#6
Klutsh

Klutsh

    InsanelyMac Protégé

  • Members
  • Pip
  • 30 posts
  • Gender:Male

View Poststroke, on Apr 20 2009, 07:00 PM, said:

You should really be using macros for stuff like that, not constants.
Would you mind providing an example?
I'm just starting out too.  -_-

#7
andyong

andyong

    InsanelyMac Protégé

  • Members
  • Pip
  • 10 posts
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];
}





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

© 2013 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Mac Netbook  |   Web hosting by CatN  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy