删除添加完成按钮这是我的代码....如何从数字键盘
`
- (void) registerForKeyboardNotifications {
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasShown:)
name:UIKeyboardDidShowNotification object:nil];
}
// Called when the UIKeyboardDidShowNotification is sent.
- (void) keyboardWasShown:(NSNotification*)notification {
[self addButtonToKeyboard];
}
#pragma -
#pragma Numeric keyboard done button
- (void) keyboardDoneClicked:(id)sender {
[txtvannum resignFirstResponder];
[txtmobnum resignFirstResponder];
// [sender resignFirstResponder];
}
- (void) addButtonToKeyboard {
// create custom button
// if(keyButton){
doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
doneButton.frame = CGRectMake(0, 163, 106, 53);
doneButton.adjustsImageWhenHighlighted = NO;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 3.0) {
[doneButton setImage:[UIImage imageNamed:@"DoneUp3.png"] forState:UIControlStateNormal];
[doneButton setImage:[UIImage imageNamed:@"DoneDown3.png"] forState:UIControlStateHighlighted];
} else {
[doneButton setImage:[UIImage imageNamed:@"DoneUp.png"] forState:UIControlStateNormal];
[doneButton setImage:[UIImage imageNamed:@"DoneDown.png"] forState:UIControlStateHighlighted];
}
[doneButton addTarget:self action:@selector(keyboardDoneClicked:) forControlEvents:UIControlEventTouchUpInside];
// locate keyboard view
UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
for(int i=0; i<[tempWindow.subviews count]; i++) {
keyboard = [tempWindow.subviews objectAtIndex:i];
// keyboard found, add the button
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 3.2) {
if([[keyboard description] hasPrefix:@"<UIPeripheralHost"] == YES)
[keyboard addSubview:doneButton];
} else {
if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES)
[keyboard addSubview:doneButton];
}
}
// }
//// else{
//// return;}
}
`
我开发了一个应用程序,它包括用户输入他们的详细资料。这里有4个文本字段。其中两个需要数字键盘。对于那个数字键盘,我在完成编辑后添加了完成按钮以辞职。但是完成按钮也适用于所有其他类型的键盘。如何添加完成按钮oly数字键盘,以便它应该隐藏所有其他呃type.I在这挣扎。请帮助。
谢谢。
发布您的代码,请。 – Frank
我已经发布我的代码,我用我的app.Pls帮助 – NSUserDefault