Skip to content

Commit 726fa5e

Browse files
committed
fix keyboard change frame incorrect
1 parent 6aba02f commit 726fa5e

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

TYAlertController.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Pod::Spec.new do |s|
22
# 名称 使用的时候pod search [name]
33
s.name = "TYAlertController"
44
# 代码库的版本
5-
s.version = "1.1.2"
5+
s.version = "1.1.3"
66
# 简介
77
s.summary = "Powerful, Easy to use alertview or popup view on controller and window, support blur effects,custom view and animation."
88
# 主页

TYAlertControllerDemo/TYAlertController/TYAlertController.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,17 +319,18 @@ - (void)singleTap:(UITapGestureRecognizer *)sender
319319
- (void)keyboardWillShow:(NSNotification*)notification{
320320
CGRect keyboardRect = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
321321

322-
CGFloat alertViewBottomEdge = CGRectGetHeight(self.view.frame) - CGRectGetMaxY(_alertView.frame);
322+
CGFloat alertViewBottomEdge = (CGRectGetHeight(self.view.frame) - CGRectGetHeight(_alertView.frame))/2 - _alertViewCenterYOffset;
323323
CGFloat differ = CGRectGetHeight(keyboardRect) - alertViewBottomEdge;
324324

325-
if (differ > 0) {
325+
if (differ >= 0) {
326326
_alertViewCenterYConstraint.constant = _alertViewCenterYOffset - differ;
327327
[UIView animateWithDuration:0.25 animations:^{
328328
[self.view layoutIfNeeded];
329329
}];
330330
}
331331
}
332332

333+
333334
- (void)keyboardWillHide:(NSNotification*)notification{
334335

335336
_alertViewCenterYConstraint.constant = _alertViewCenterYOffset;

TYAlertControllerDemo/ViewController.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ @implementation ViewController
2323
- (void)viewDidLoad {
2424
[super viewDidLoad];
2525
// Do any additional setup after loading the view, typically from a nib.
26+
2627
}
2728

2829

0 commit comments

Comments
 (0)