Open AlexanderZubkov opened 10 years ago
I had the same issue today, and I chose a way around : I moved the private property alertWindow from CXAlertView.m to the public interface CXAlertView.h , and then : CXAlertView* alert = [[CXAlertView alloc] blah bla ] [...] [alert show]; alert.alertWindow.frame = CGRectMake([...]);
cheers, l.
That's is a big problem,I got this one too
I modified CXAlertViewController for solving this issue. Here is some code:
(void)viewDidLoad { [super viewDidLoad]; [self.alertView setup];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; }
// Handle keyboard show/hide changes
(void)keyboardWillShow: (NSNotification *)notification { CGSize screenSize = self.view.frame.size; CGSize dialogSize = self.alertView.frame.size; CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation]; if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) { CGFloat tmp = keyboardSize.height; keyboardSize.height = keyboardSize.width; keyboardSize.width = tmp; }
[UIView animateWithDuration:0.3f delay:0.0 options:UIViewAnimationOptionTransitionNone animations:^{ self.alertView.frame = CGRectMake((screenSize.width - dialogSize.width) / 2, (screenSize.height - keyboardSize.height - dialogSize.height) / 2, dialogSize.width, dialogSize.height); } completion:nil ]; }
(void)keyboardWillHide: (NSNotification *)notification { CGSize screenSize = self.view.frame.size; CGSize dialogSize = self.alertView.frame.size;
[UIView animateWithDuration:0.3f delay:0.0 options:UIViewAnimationOptionTransitionNone animations:^{ self.alertView.frame = CGRectMake((screenSize.width - dialogSize.width) / 2, (screenSize.height - dialogSize.height) / 2, dialogSize.width, dialogSize.height); } completion:nil ]; }
Thank you @miriusus !! Make a push request with your code!!!
+1
Hello. I've added a textview as a content view and when the keyboard comes up it hides half of alert view, i.e. alert view is not moving up. Is it possible to make it to move up? Thanks.