Emoji changes my keyboard to its... - iphone

I have some problem. On start of my application I automatically show number pad keyboard(I send becomeFirstResponder to one of textfields) . But if user has used emoji keyboard before my application, emoji keyboard is shown. How can I avoid it? I want to show exactly number pad, but not emoji keyboard.

Use the keyboard notification and track the keyboard by using some BOOL variables,
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(keyboardWasShown:) name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(keyboardWasHidden:) name:UIKeyboardDidHideNotification object:nil];
Check if a keyboard is already there by using the BOOL var. If its there resign it and show your keyboard.

Related

How to know the UIkeyboard is appeared or not in iOS? [duplicate]

This question already has answers here:
How can I programmatically check whether a keyboard is present in iOS app?
(21 answers)
Closed 9 years ago.
How can I find the UIKeyboard is open in my application or not?
I don't want to use any delegate methods of UITextField.
Please suggest any solution.
Thanks in advance.
Test this :
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
From official Documentation.
Use keyboard notification for check status of UIKeyBoard.
Keyboard Notifications:
When the system shows or hides the keyboard, it posts several keyboard notifications. These notifications contain information about the keyboard, including its size, which you can use for calculations that involve moving views. Registering for these notifications is the only way to get some types of information about the keyboard. The system delivers the following notifications for keyboard-related events:
UIKeyboardWillShowNotification
UIKeyboardDidShowNotification
UIKeyboardWillHideNotification
UIKeyboardDidHideNotification

Default Keyboard appears in iPhone instead of my custom keyboard

I am making a custom keyboard in my app for iPhone. But when I tap on the UITextField the default keyboard also appears. Where as I want only my keyboard to pop-up on the screen. How do I stop default keyboard from appearing on the screen?
You can try the following line of code
your_TextField.inputView = your_CustomKeyboard;
I am not confirm that it will work for your custom Keyboard i tried this to use a datepicker as inputview and it did worked so it may help you
I got the answer to my question. Since I am new here i cudnt post an answer b4 8 hrs after my own question post. And yes Tejeshwar Gill, Thanks for the response and my solution matches your approach. Thanks again.
I used the NSNotificationCenter to notify me when the keyboard appears. I had used this method to resize my tableview when the keyboard appears, but that was quite some time before. So it didnt click me instantly then.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(hideKeyboard:)
name:UIKeyboardWillShowNotification
object:nil];
You need to hide the default keyboard inorder to show your custom keyboard. So use this:-
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(keyboardDidHide:) name:UIKeyboardDidHideNotification object:nil]; and in the method keyboardDidHide: , add [keyboard resignFirstResponder].

Can I disable the keyboard from showing in a UIWebView?

Is it possible to disable the keyboard from showing when a webpage element is selected inside a UIWebView?
Register for a keyboard notification:
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(keyboardWillShow) name:UIKeyboardWillShowNotification object:nil];
And then you can stop it from showing by placing the following code in keyboardWillShow :
UITextField *dummyTextField = etc.
//Basically, create a dummy uitextfield that you never show.
//I can't remember all the syntax :)
[dummyTextField becomeFirstResponder];
[dummyTextField resignFirstResponder];
//Keyboard should be gone. Hoorah!
Not sure 100% if this will work without flaws. If the keyboard starts to animate then hides itself again, you could use
[UIView enableAnimations:NO];
If the keyboard doesn't like being resigned while it's showing then you could try changing the inputView property of the dummy textField to some dummy UIView instead.
Hopefully this should get you somewhere!

Iphone web application problem on iphone keyboard open

I have a problem of layout in view my website on iphone/Ipad, when the iphone keyboard open The whole website moved to top due to which user will not be able to view the top content while the keyboard is open. When keyboard is close the website will be back to its original position.
Implement the below nottification methods in init method of the controller showing your website:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(keyboardWasShown:)
name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(keyboardWasHidden:)
name:UIKeyboardDidHideNotification object:nil];
try setting the frame of your website in the corresponding notification methods (keyboardWasShown,keyboardWasHidden). Eg:- Say your webSiteView is the view disaplying your website and x,y are the coordinates of the view when keyboard is not visible. When the keyBoard is shown, set the frame of the webSiteView with the new x1 and y1 coordinates that will show the view the way you want.
- (void)keyboardWasShown: (id)sender {
[webSiteView setFrame:CGRectMake(x1,y1,w,h)];
}
- (void)keyboardWasHidden: (id)sender {
[webSiteView setFrame:CGRectMake(x,y,w,h)];
}
Also if you are not able to see the entire webSite, try adding your webSiteView into a scrollView and set the frame of the ScrollView in the notification methods.

two UITextFields - slide first Keyboard out and next in

so in my viewdidload i got something like
[nameTextField becomeFirstResponder]
now after a button gets klicked, i want to slide out the keyboard of this textfield, and slide another keyboard of another textfield in.
i thought about
[nameTextField resignFirstResponder];
[dateTextField becomeFirstResponder];
but the other keyboard shows up immediately.
commenting the [dateTextField becomeFirstResponder]; out, effects that my nameTextField keyboard slides out as i wanted.
any ideas how to do this?
thanks!
Is there a reason why you want to do this? It will obviously increase the time it takes for a user to enter information, which I know would bug me.
But if you do really want this effect, then I would look at something like this:
[dateTextField performSelector:#selector(becomeFirstResponder) withObject:nil afterDelay:timeDelay];
Where timeDelay is the amount of time it takes to dismiss the first keyboard.
You can register to observe these notifications: UIKeyboardWillShowNotification , UIKeyboardWillHideNotification. That will let you keep track of what is going on, but it can easily get pretty complicated so Tom Irving's suggestion might be easier to work with.
To get notifications on keyboard hiding and showing, have a look at
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(keyboardDidHide:)
name:UIKeyboardDidHideNotification object:[self view].window];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(keyboardDidShow:)
name:UIKeyboardDidShowNotification object:[self view].window];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification object:[self view].window];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification object:[self view].window];
and add appropriate methods like
-(void)keyboardWillShow:(NSNotification*)notif
-(void)keyboardWillHide:(NSNotification*)notif
-(void)keyboardDidShow:(NSNotification*)notif
-(void)keyboardDidHide:(NSNotification*)notif
Then you can connect the animations any way you like.
Be sure to NSLog() all of them, they are not always called when you would expect them (the notorious one being when you go from one field to another, and you receive the willhide and willshow immediately)