Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 03-27-2009, 09:59 AM   #26 (permalink)
New Member
 
Join Date: Mar 2009
Posts: 5
kaktusok is on a distinguished road
Default

Malork, thank you very much !!!
kaktusok is offline   Reply With Quote
Old 03-27-2009, 10:24 AM   #27 (permalink)
Registered Member
 
Join Date: Mar 2009
Location: the Netherlands
Posts: 19
Malork is on a distinguished road
Send a message via MSN to Malork
Default

Quote:
Originally Posted by kaktusok View Post
Malork, thank you very much !!!
You're welcome I know how annoying these things can be
Malork is offline   Reply With Quote
Old 06-05-2009, 08:51 AM   #28 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 9
Roost is on a distinguished road
Default Thanx

Thanx, this worked perfectly.

Quote:
Originally Posted by incorrect.user View Post
To hide a keyboard u need just to setup a callback (i.e. IBAction) for the event "Did End On Exit" of UITextField in the InterfaceBuilder. So make ur UITextField an IBOutlet and put an empty IBAction as a callback for "Did End On Exit". That's all.

Like this:

//header

@interface MyView : UIView
{
IBOutlet UITextField *name;
}

- (IBAction)doneButtonOnKeyboardPressed: (id)sender;

//m-file

@implementation MyView

- (IBAction)doneButtonOnKeyboardPressed: (id)sender
{}

@end
Roost is offline   Reply With Quote
Old 08-05-2009, 04:18 PM   #29 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 8
chief_lunatic is on a distinguished road
Default UITextField Confusion

It seems like there is a lot of confusion surrounding this topic, so here is a code example showing how to programatically create a functional UITextField

Code:
/*
MyTextFieldView.h
The important notes here are that we have...
1. A new class of superclass UIView
2. The class contains a UITextField class member
3. The class implements the UITextFieldDelegate interface
*/
#import <UIKit/UIKit.h>

@interface MyTextFieldView : UIView <UITextFieldDelegate>{
	UITextField *my_text_field;
}

@end
Code:
/*
MyTextFieldView.m
*/


#import "MyTextFieldView.h"

@implementation MyTextFieldView

- (id)initWithFrame:(CGRect) myframe {
        self = [super initWithFrame:myframe];

        //Setup the location of the text field (top, full width)
	int w = [[UIScreen mainScreen] applicationFrame].size.width;
        CGRect text_field_rect = CGRectMake(0,0,w,30);

        //initialize the text field
	my_text_field = [[UITextField alloc] initWithFrame:text_field_rect];
	
       //tell the text field that MyTextFieldView will handle its events
       [my_text_field setDelegate:self];

        //A little visual formatting to make things pretty
	my_text_field.borderStyle = UITextBorderStyleBezel;
        my_text_field.textColor = [UIColor blackColor];
	my_text_field.font = [UIFont systemFontOfSize:17.0];
        my_text_field.placeholder = @"<enter text>";
        my_text_field.backgroundColor = [UIColor whiteColor];	

       //add the text field to the view
       [self addSubview:my_text_field];

       return self;
}

//UITextFieldDelegateMethods
//When the keyboard return button is pressed...
//The UITextField "my_text_field" tells its delegate (ie this
//instance of MyTextFieldView) to call the method "textFieldShouldReturn"
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
        //We resign the first responder
        //This closes the keyboard
	[textField resignFirstResponder];

        //Do what ever other fanciness you want
        //TODO: fanciness

        //Return YES to confirm the UITextField is returning
	return YES;
}

- (void)dealloc {
    [super dealloc];
}


@end
hope that helps
chief_lunatic is offline   Reply With Quote
Old 08-06-2009, 04:31 PM   #30 (permalink)
New Member
 
Join Date: Oct 2008
Posts: 3
jdbholmes is on a distinguished road
Default Nice

Quote:
Originally Posted by kilobytedump View Post
I simply point the Did End On Exit to a dummy piece of code.

Dismisses the keyboard just fine.
code in the viewcontroller.m

-(IBAction)fakeid)sender
{
[passkey resignFirstResponder];
[upc resignFirstResponder];
[registrantId resignFirstResponder];
}

code in the viewcontroller.h

-(IBAction)fake: (id) sender;

in IB pointed my text fields to fileowner fake


PUURFECT thanks for the post
jdbholmes is offline   Reply With Quote
Old 04-19-2010, 09:10 PM   #31 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 8
Adam Allen is on a distinguished road
Default

The key piece of code being:

Code:
@interface MyTextFieldView : UIView <UITextFieldDelegate>{
That's what allows you to delegate the UITextField to MyTextFieldView and use the textFieldShouldReturn method.
Adam Allen is offline   Reply With Quote
Old 12-08-2010, 11:25 PM   #32 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 2
Gonu22 is on a distinguished road
Smile

Quote:
Originally Posted by nirmala1982 View Post
Can Somebody tell me how to dismiss keyboard on click of UITextField which i created in interface builder because i want to select data from the UIPickerView to fill the UITextField instead of typing the text from the keyboard
Hey i had the same problem. Call the UITextFieldDelegate protocol. and then try mytextfield.delegate=self;
if this doesnt work load ur textfield programtically n not using IB.
Dont forget to add the -(BOOL) textFieldShouldreturn method from textfieldDelegate.

If you want values from Picker to be loaded. Load the pickerview in textfieldShouldBeginEditing method...

ignore if this you already know...
Gonu22 is offline   Reply With Quote
Old 09-10-2011, 05:14 PM   #33 (permalink)
[[Brain alloc]init];
 
fhsjaagshs's Avatar
 
Join Date: Aug 2011
Location: New Jersey
Age: 15
Posts: 92
fhsjaagshs is on a distinguished road
Default

Since I am so tired of you guys asking all of these dumb questions, I will give a good response in the hopes that you guys will stop asking them:

Before we begin, make sure you have added UITextFieldDelegate (or UITextViewDelegate) delegate in the <> in the header file's interface.

In order to dismiss a keyboard, you must first have a UITextField or UITextView. Those two classes are exactly the same, except UITextView is a UITextField with a UIScrollView in it. This means that everything that works with UITextField will work with UITextView (minus a few things).

To dismiss a keyboard, we want to call [textField resignFirstResponder];
(where textField is any UTextField or UITextView)

However, Just dismissing it anywhere is probably against apple's guidelines.

This is why we use the delegate, in order to dismiss the keyboard, create an IBAction and call the aforementioned thingy (or use a delegate method)

If you used the delegate method, make sure that you used the one that starts with textFieldDidEndOnExit.

Otherwise, connect the IBAction to the UITextField (or UITextView) for the event: DidEndOnExit.

you now have a UITextField (or UITextView) that dismisses when the return button is pressed.

One more thing: make sure to set the textField's delegate to self in the viewDidLoad method!!!!
fhsjaagshs is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 349
11 members and 338 guests
givensur, glenn_sayers, guusleijsten, ipodphone, jbro, mediaspree, mottdog, mtl_tech_guy, Punkjumper, vilisei, whitey99
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,114
Posts: 402,883
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:31 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0