gpt4 book ai didi

ios - Textview Frame 被挤压无法恢复原状?

转载 作者:行者123 更新时间:2023-11-29 12:21:13 26 4
gpt4 key购买 nike

enter image description here

enter image description here

keyboardWillShow 方法实现:

 - (void)keyboardWillShow:(NSNotification *)notification 
{

[UIView beginAnimations:nil context:nil];
CGRect endRect = [[notification.userInfo
objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
CGRect newRect = txtNotes.frame;
//Down size your text view
newRect.size.height -= endRect.size.height;
txtNotes.frame = newRect;
[UIView commitAnimations];
}

keyboardWillHide 方法实现:

  - (void)keyboardWillHide:(NSNotification *)notification
{
// Resize your textview when keyboard is going to hide
UIEdgeInsets contentInsets = UIEdgeInsetsZero;
txtNotes.contentInset = contentInsets;
txtNotes.scrollIndicatorInsets = contentInsets;

}

最佳答案

一些事情:

1) META:您应该在每个代码行之前添加 4 个空格以使代码正确显示。

2) 这看起来像是一个基本的约束问题。你应该检查 Auto Layout你的 Storyboard。

关于ios - Textview Frame 被挤压无法恢复原状?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30572972/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com