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

View Single Post
Old 11-30-2008, 08:35 AM   #1 (permalink)
NickFalk
Registered Member
 
NickFalk's Avatar
 
Join Date: Oct 2008
Location: Oslo, Norway
Posts: 20
NickFalk is on a distinguished road
Default Problem with resignFirstResponder

Hi there. I'm ploughing through "Beginning iPhone Development" from Apress and thought I had started to get to grips with the basics. Unfortunately I seem to have been mistaken.

I'm trying to close the keyboard with a UIButton (in addition to the "Done") field. (The idea is to eventually make this into an invisible "background" button allowing the user to close any keyboard when tapping outside the fields.

I have the following files:
(.h)
Code:
#import <UIKit/UIKit.h>

@interface FunViewViewController : UIViewController {
	IBOutlet UITextField *nameField;
	IBOutlet UITextField *numberField;

}
@property (nonatomic, retain) UITextField *nameField;
@property (nonatomic, retain) UITextField *numberField;
-(IBAction) textFieldDoneEditing:(id)sender;
-(IBAction) backgroundClick:(id)sender;

@end
(.m)
Code:
#import "FunViewViewController.h"

@implementation FunViewViewController

@synthesize nameField;
@synthesize numberField;


-(IBAction) textFieldDoneEditing:(id)sender
{
	[nameField resignFirstResponder];
}

-(IBAction) backgroundClick:(id)sender 
{
	[nameField resignFirstResponder]; 
	NSLog(@"Here I am");
}

...

@end
Now, the [nameField resignFirstResponder] works fine when it's called in the textFieldDoneEditing action (which is called directly from the 'Did End On Exit' in the IB.

When calling the [nameField resignFirstResponder] in the backgroundClick action it simply doesn't work. I know the action itself is called OK as the debugger does return the "Here I am" string.

It's probably some basic concept that I've missed completely, but that's the life of a newbie. Any help would be highly appreciated! Cheers!
NickFalk is offline   Reply With Quote
 

» Advertisements
» Online Users: 399
20 members and 379 guests
13dario13, aaronredmond844, apatsufas, blueorb, Clouds, cserft, DaveDee, eski, guusleijsten, jacob7khan, jeroenkeij, Lily.P, MysticLine, networ, QuantumDoja, sacha1996, shweta128, Vijithasri06, Warblr, zhaoningmei
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,597
Threads: 94,084
Posts: 402,781
Top Poster: BrianSlick (7,990)
Welcome to our newest member, aaronredmond844
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:40 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.