Note that there are some explanatory texts on larger screens.

plurals
  1. POdone button only for numberpad keyboard
    primarykey
    data
    text
    <p>I am working on the iPhone application. I have four textfields in one of the view. In these four textfield I have one textfield in which there will be use of numberpad keyboard. But on numberpad keyboard there is no return key. So I have added "Done"button programmatically by using following code. </p> <pre><code> if ([[[UIDevice currentDevice] systemVersion] floatValue] &gt;= 3.2) { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil]; } else { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; } - (void)addButtonToKeyboard { // create custom button UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeCustom]; doneButton.frame = CGRectMake(0, 163, 106, 53); doneButton.adjustsImageWhenHighlighted = NO; if ([[[UIDevice currentDevice] systemVersion] floatValue] &gt;= 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(doneButton:) forControlEvents:UIControlEventTouchUpInside]; // locate keyboard view UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1]; UIView* keyboard; for(int i=0; i&lt;[tempWindow.subviews count]; i++) { keyboard = [tempWindow.subviews objectAtIndex:i]; // keyboard found, add the button if ([[[UIDevice currentDevice] systemVersion] floatValue] &gt;= 3.2) { if([[keyboard description] hasPrefix:@"&lt;UIPeripheralHost"] == YES) [keyboard addSubview:doneButton]; } else { if([[keyboard description] hasPrefix:@"&lt;UIKeyboard"] == YES) [keyboard addSubview:doneButton]; } } } - (void)keyboardWillShow:(NSNotification *)note { // if clause is just an additional precaution, you could also dismiss it if ([[[UIDevice currentDevice] systemVersion] floatValue] &lt; 3.2) { [self addButtonToKeyboard]; } } - (void)keyboardDidShow:(NSNotification *)note { // if clause is just an additional precaution, you could also dismiss it if ([[[UIDevice currentDevice] systemVersion] floatValue] &gt;= 3.2) { [self addButtonToKeyboard]; } } - (void)doneButton:(id)sender { NSLog(@"doneButton"); NSLog(@"Input: %@", contactno.text); [contactno resignFirstResponder]; } </code></pre> <p>It is fine for this particular textfield. But this button is also get add for the rest of the textfields. How could unhide this button for other textfields. <img src="https://i.stack.imgur.com/FNOXK.png" alt="enter image description here"></p> <p>thanks alot in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload