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@@!!