Keyboard notifications triggered unnecessarily upon showing UIAlertview on iOS8.3
Keyboard notifications triggered unnecessarily upon showing UIAlertview on iOS8.3
- Subject: Keyboard notifications triggered unnecessarily upon showing UIAlertview on iOS8.3
- From: Devarshi Kulshreshtha <email@hidden>
- Date: Tue, 19 May 2015 12:51:54 +0530
Greetings!
We are observing unusual behaviour with respect to Keyboard willshow & will
hide notification on iOS 8.3.
The viewcontroler (listenig to keyboard notifications) has a textfiled and
upon clicking and upon tapping the submit button, the method first resigns
the first responder from textfield, and shows an alert to inform warning.
Everything works fine, it dismisses the keyboard and shows up the alert as
expected. (calls the UIKeyboardWillHideNotification method too).
However, on 8.3, after tapping OK/Cancel on Alertview delegate, it
dismisses the alert and it calls up UIKeyboardWillShowNotification &
UIKeyboardWillHideNotification respectively, though it was not supposed to
be called! This was not expected, as the keyboard was already dismissed
before dispalying the alert!
Here is the code snippet, that we are trying:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification
object:nil];
}
- (IBAction)ShowAlert:(id)sender {
[self.TxtField resignFirstResponder];
//This woudln't make any diff either :(
[self.view endEditing:YES];
[self ShowAlertForTest];
}
-(void)ShowAlertForTest{
UIAlertView *theAlertView= [[UIAlertView alloc]initWithTitle:@"Title"
message:@"msg"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Yes",
nil];
[theAlertView show];
}
- (void)alertView:(UIAlertView *)alertView
clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSLog(@"buttonIndex = %ld",buttonIndex);
}
- (void)keyboardWillShow:(NSNotification *)aNotification
{
NSLog(@"keyboardWillShow");
}
- (void)keyboardWillHide:(NSNotification *)aNotification
{
NSLog(@"keyboardWillHide");
}
This behaviour is causing issues in our app, when there are cascading
alerts triggered from the previous alertview'd delegate - bringing up the
keyboard in unneeded situations.
Any help /advice is greatly appreciated!
--
Thanks,
Devarshi
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden