我想要键盘高度
CGRect frameBegin = [[notification.userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue] ;CGRect frameEnd = [[notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];CGRect resultBegin = [self.vIEw convertRect:frameBegin fromVIEw:nil];CGRect resultEnd = [self.vIEw convertRect:frameEnd fromVIEw:nil];CGfloat kbdHeight = resultBegin.origin.y - resultEnd.origin.y;
问题是当键盘出现时,此模态视图会跳起来.在这种情况下如何计算键盘的顶部边框坐标?
解决方法 你可以这样做:1. Register for keyboard notifications:[[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(myTextVIEwHeightAdjustMethod:) name:UIKeyboarDWillShowNotification object:nil];[[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(myTextVIEwHeightAdjustMethod:) name:UIKeyboardDIDShowNotification object:nil];2. Calculate intersection and adjust textVIEw height with the bottom constraint - (voID)myTextVIEwHeightAdjustMethod:(NSNotification *)notification { NSDictionary *userInfo = [notification userInfo]; CGRect keyboardFinalFrame = [[userInfo emf_ObjectOrNilForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]; CGPoint keyboardOriginInVIEw = [self.vIEw convertPoint:keyboardFinalFrame.origin fromVIEw:nil]; CGfloat intersectionY = CGRectGetMaxY(self.vIEw.frame) - keyboardOriginInVIEw.y; if (intersectionY >= 0) { self.textVIEwBottomConstraint.constant = intersectionY + originalTextVIEwBottomConstraint; [self.textVIEw setNeedsLayout]; }
请记得取消注册通知.
总结以上是内存溢出为你收集整理的ios – iPad上的UIModalPresentationFormSheet.键盘出现时如何调整UITextView高度全部内容,希望文章能够帮你解决ios – iPad上的UIModalPresentationFormSheet.键盘出现时如何调整UITextView高度所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)