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 09-09-2010, 06:40 AM   #1 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 16
eddyxd is on a distinguished road
Default I can't resign to firstresponder

Hi, everyone~ I am a newbie for IPhone SDK developer in Taiwan.

I want to make a UITextField to let user key in their salary into this field.

I have refered to many useful threads in this forum, and finally I can make a custome "done" button above my number pad keyboard (thanks god A_A~)

But i get a problem now@@:

here is my code :
Code:
- (void) keyboardWillShow:(NSNotification *)note {
	NSLog(@"get Keyboard show notification!");
	//begin to find keyboard view
	UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
	UIView* keyboard;
	for(int i=0;i<[tempWindow.subviews count];i++){
		keyboard = [tempWindow.subviews objectAtIndex:i];
		NSLog(@"description=%@",[keyboard description]);
		if([[keyboard description] hasPrefix:@"<UIKeyboard"]==YES){
			NSLog(@"we find keyboard subview!! in i=%d",i);
			//do custom change!
			CGRect frame = CGRectMake(0, 165, 105, 55);
			UIButton *checkButton = [[UIButton alloc] initWithFrame:frame];
			[checkButton setTitle:@"Check" forState:UIControlStateNormal];
			[checkButton setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
			[checkButton setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
			[checkButton addTarget:self action:@selector(clickCheck:) forControlEvents:UIControlEventTouchUpInside];
			[keyboard addSubview:checkButton];
			
			return;
		}
	}
	NSLog(@"Error : can't find keybaord subview!");
	return;
}

- (void) clickCheck:(id)sender{
	NSLog(@"clickCheck!");
	[sender resignFirstResponder];
}
-------------------
I could get the Log : "clickCheck" when I press the checkButton above number pad, so I assume the Button really did his Job@@~

But I can't return back the background page before the popping up Keyboard.

I have searched many thread and find we can use resignFirstResponder to do what I want, and I also test this function in other project to cancel a normal Keyboard with Done Key as many post mentioned.

But It doesn't work in this situation at all~QQ~


Can anyone help me or tell me how should I do?

I will appreciate for you! thx@@!!

Last edited by eddyxd; 09-09-2010 at 06:42 AM.
eddyxd is offline   Reply With Quote
Old 09-09-2010, 02:06 PM   #2 (permalink)
Fly-by-night Innovator
 
Join Date: Jun 2010
Posts: 364
musicwind95 is on a distinguished road
Default

If you want to dismiss the keyboard, hook up your custom Done button to an IBAction. Inside that method, just call [self.inputTextField resignFirstResponder].
__________________
If I have helped you, please consider donating. I use PayPal. It would mean a lot to me!


For more iOS Development, check out my blog—Cups of Cocoa. All visitors welcome, but especially beginners!

Hope I have helped!

Please check out IceFall, a new action game available in the App Store!
musicwind95 is offline   Reply With Quote
Old 09-09-2010, 09:01 PM   #3 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 16
eddyxd is on a distinguished road
Smile

Quote:
Originally Posted by musicwind95 View Post
If you want to dismiss the keyboard, hook up your custom Done button to an IBAction. Inside that method, just call [self.inputTextField resignFirstResponder].
THX!!!!!!!!!

It really works.

I have tried many forms to call resignFirstResponder, but not tried this one@@.

Now I get it and really thank you!.
eddyxd is offline   Reply With Quote
Reply

Bookmarks

Tags
keyboard, resignfirstresponder

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: 335
10 members and 325 guests
bignoggins, carlandrews, flamingliquid, hzwegjxg, ilmman, jenniead38, linkmx, nadav@webtview.com, stanny
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

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