問題が発生した後、数値キーパッドにRETURNボタンを追加することができました。uikeyboardと呼ばれるuitextフィールドを検出する
他のデータを他のuitextフィールドに取り込むときに削除したいのは、キーボードを使用するたびにそのボタンが現れるためです。キーボードの一部です。
KeyBoardDidShowのイベントハンドラを追加するイム、それ以外の場合は仕事をdoesntの、
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardDidShowNotification object:nil];
はその後KeyboarWillShow
- (void)keyboardWillShow:(NSNotification *)note {
// create custom button
NSLog(@"El note es: %@", note);
UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
doneButton.frame = CGRectMake(0, 163, 106, 53);
doneButton.adjustsImageWhenHighlighted = NO;
[doneButton setImage:[UIImage imageNamed:@"done.jpg"] forState:UIControlStateNormal];
[doneButton setImage:[UIImage imageNamed:@"done_pressed.jpg"] forState:UIControlStateHighlighted];
[doneButton addTarget:self action:@selector(doneButton:) forControlEvents:UIControlEventTouchUpInside];
UIWindow *keyboardWindow = nil;
for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) {
if (![[testWindow class] isEqual:[UIWindow class]]) {
keyboardWindow = testWindow;
break;
}
}
if (!keyboardWindow) return;
// Locate UIKeyboard.
UIView *foundKeyboard = nil;
for (UIView *possibleKeyboard in [keyboardWindow subviews]) {
// iOS 4 sticks the UIKeyboard inside a UIPeripheralHostView.
if ([[possibleKeyboard description] hasPrefix:@"<UIPeripheralHostView"]) {
possibleKeyboard = [[possibleKeyboard subviews] objectAtIndex:0];
}
if ([[possibleKeyboard description] hasPrefix:@"<UIKeyboard"]) {
foundKeyboard = possibleKeyboard;
break;
}
}
if (foundKeyboard) {
// Add the button to foundKeyboard.
[foundKeyboard addSubview:doneButton];
}
}
に事は、これは常にボタンを作成することです!明らかに!私は特定のuitextfieldsでボタンを作成したいと思っています。
メソッド - (BOOL)textFieldShouldBeginEditing:最初は実行しませんでした。残りの部分はなぜですか?しかし、もし私がuitextフィールドがキーボードを呼んでいるのを知ることができれば、私の髪は再び成長し、私はよりスリムになるでしょう、誰も助けることができますか?
を[OK]を、私はuitextfieldsためのデリゲートのを修正しました。しかし、問題は、textFieldShouldBeginEditing:が実行されたときにキーボードがロードされないため、キーボードの表示が巧妙ではないので、そこに戻るボタンを追加できないということです。それはkeyboardwillshowからaccesibleですが、私は各uitextfieldの情報にアクセスできません。どのuitextフィールドが最後にタップされたのかを保存する属性を保持する必要がありますか? – subharb
yep ...最後のUITextFieldを保存する属性を保持すると問題ありません。 –