detect iPad keyboard Hiding button - ipad

Hi is there any way to detect iPad keyboard hiding button ? i mean when user press this button :
something going to happen !

I'm not sure what you want to accomplish, but maybe this can help you: Register with NSNotificationCenter to receive the UIKeyboardWillHideNotification and/or UIKeyboardDidHideNotification.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(myKeyboardWillHideHandler:)
name:UIKeyboardWillHideNotification
object:nil];
...
- (void) myKeyboardWillHideHandler:(NSNotification *)notification {
NSLog(#"Keyboard wants to hide. What a coward.");
}

put this to viewDidLoad
// register to track event when user presses hide keyboard button on bottom right cornor for iPAD
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(textFieldShouldReturn:) name:UIKeyboardWillHideNotification object:nil];
and this will make your - (BOOL)textFieldShouldReturn:(UITextField *)textField; delegate method to get called when keyboard down button is pressed in iPAD.

[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(textFieldShouldReturn:) name:UIKeyboardWillHideNotification object:nil];
This actually crashes on the go.
But if you call a custom method, like:
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(myCustomeMethodToResignTextFieldResponder) name:UIKeyboardWillHideNotification object:nil];
Then it will work just fine.. :-)

with Javascript
I found a workaroud for iPad IOS7. I will test on IOS8 to make sure it works. So basically I create a listener on every FOCUSOUT event (for all my texts) and I call my function.
It fires when you have your keyboard open and when you close your "keyboard". It doesn't fire when you select another text field or button, because it targets on null. If you use in combination with keydown, you can save multiple value and call your submit function only when you release your keyboard.
document.addEventListener('focusout', function(e) {
if (e.relatedTarget == null){
alert("close keyboard without click on something else");
callYourFunction();
}
});

Related

iOS: listener of the "hide" button in the keyboard

I'm using the
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField
to remove the keyboard when the user click on the return or done button and it works perfectly. My problem is that when my application is in the landscape mode or when I run it in the iPad, the "hide" button is added in the keyboard (the button displayed in the picture). When I click it, the keyboard is hided but the textFieldShouldReturn is never called.
How can I detect when this button is tapped?
Receiving Keyboard Notifications
When the keyboard is shown or hidden, iOS sends out the following notifications to any registered observers:
UIKeyboardWillShowNotification
UIKeyboardDidShowNotification
UIKeyboardWillHideNotification
UIKeyboardDidHideNotification
you can get the detail information from Apple document
for e.g
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(keyboardhideHandle:)
name:UIKeyboardWillHideNotification
object:nil];
- (void) keyboardhideHandle:(NSNotification *)notification {
NSLog(#"you received the action here");
}
To detect when the keyboard from a UITextField is being brought up we could setup the observers in viewDidLoad, like this for example:
- (void)viewDidLoad {
[super viewDidLoad];
// setup keyboard observers
[[NSNotificationCenter defaultCenter]addObserver:self selector:#selector(keyboardCameUp:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self selector:#selector(keyboardWentAway:) name:UIKeyboardWillHideNotification object:nil];
}
These observers will call a method in our class (using #selector). Mine are called keyboardCameUp and keyboardWentAway:
- (void)keyboardCameUp:(NSNotification *)notification {
NSLog(#"Keyboard came up!");
}
- (void)keyboardWentAway:(NSNotification *)notification {
NSLog(#"Keyboard went away!");
}
src: e.g. http://pinkstone.co.uk

How to call Done button of mpmovieplayer without touch or click of Done button on screen in ios?

How to call Done button of mpmovieplayer without touch or click of Done button on screen in ios ?
I mean how to access or call Done button manually after declare of notification.
like this....
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(exitedFullscreen:) name:MPMoviePlayerDidExitFullscreenNotification object:nil];
- (void)willExitFullscreen:(NSNotification*)notification{
NSLog(#"willExitFullscreen");}
so here how to call exitedFullscreen. ?

Adjust UITextField with iPad split/moved keyboard

I'm currently implementing in my app functionality that my UITextField would not be covered by the keyboard (when edited). It is pretty straight forward with the keyboard notification methods :
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(p_keyboardWasShown:)
name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(p_keyboardWillBeHidden:)
name:UIKeyboardWillHideNotification object:nil];
But the problem with this is that they do not launch when the keyboard is in a different place (for example top) or split.
Any advice how to handle these situations?
Great article Working With Keyboard on iOS: http://macoscope.com/blog/working-with-keyboard-on-ios/

textView resignFirstResponder not firing UIKeyboardWillHideNotification

I have a UIView which contains UITexView and a Button.
I have a delegate UITextViewDelegate.
When I first set the cursor on the UITextView, the delegate function "textViewShouldEndEditing" gets called, and this function triggers the UIKeyboardWillShowNotification notification. So far so good.
When I click on the button, I call the function [self.textView resignFirstResponder];, this function then calls the delegate "textViewShouldEndEditing", but the notification UIKeyboardWillHideNotification never gets called.
I have a listener for the notification
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(_keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:nil];
Is there anything missing ???
[self.view endEditing:YES]; is the trick, Thank you all for your help
you should post a notification to the notification center in the following way
[[NSNotificationCenter defaultCenter]
postNotificationName:#"TestNotification"
object:self];
and you can check whether the notification has received or not in the following way
if ([[notification name] isEqualToString:#"TestNotification"])
NSLog (#"Successfully received the test notification!");
Is your code is like this, check and let me know
-(void)viewDidAppear:(BOOL)animated{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:nil];
}
-(void) keyboardWillHide:(NSNotification *)note{
NSLog(#"test");
}

Can UIWebView catche the event caused by pressing the MediaPlayer's done button

I want to use UIWebView to load URL and play vedios. When I press done button in MediaPlayer control on the UIWebView, I want to do something.
My Question is, in this case can it be OK, or does the UIWwebView has a delegate method to do after pressing done button?
The "Done" button only shows up in full screen mode. You can detect the end of full screen mode by observing the #"UIMoviePlayerControllerDidExitFullscreenNotification" mode:
- (void)viewDidLoad
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(moviePlayerDidExitFullscreen:)
name:#"UIMoviePlayerControllerDidExitFullscreenNotification"
object:nil];
}
- (void)viewDidUnload
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)moviePlayerDidExitFullScreen:(NSNotification *)notification
{
// This is where you do whatever you want because the user pressed "Done".
}
The UIMoviePlayerControllerDidExitFullscreenNotification is not documented, so I don't know if it will pass App Store review. If you're not planning to distribute via the App Store, it shouldn't matter.

Resources