[英]iOS:I have a requirement with textview become first responder
When the [sendTextField becomeFirstResponder]
, the keyboard
will upspring
, and self.view
will upspring too. 当
[sendTextField becomeFirstResponder]
时, keyboard
会upspring
,并self.view
将upspring了。
I have a requirement , when [sendTextField becomeFirstResponder]
, the keyboard
upspring, but self.view do not upspring? 我有一个要求,当
[sendTextField becomeFirstResponder]
, keyboard
[sendTextField becomeFirstResponder]
,但是self.view不会弹出吗?
EDIT:For more clear for my question, I add a picture: 编辑:为使我的问题更清楚,我添加了一张图片:
My requirement is: The tableview
do not upspring and the textview's back
upspring with keyboard
popup. 我的要求是:
tableview
不能弹起,而textview's back
keyboard
弹起是可以弹起的。
EDIT:For Ajay Gabani
's answer, I test in my ipnone-5s
using TPKeyboardAvoiding
's example , and I found this, the tableView also upspring
with the keyboard
, the picture will show: 编辑:对于
Ajay Gabani
的回答,我在我的测试ipnone-5s
使用TPKeyboardAvoiding
的例子,我发现这一点,也的tableView upspring
与keyboard
,画面将显示:
The origin status: 来源状态:
The tableview upspring: tableview的后代:
Sorry I am not able to comment on your question. 抱歉,我无法评论您的问题。
For your case "when [sendTextField becomeFirstResponder], the keyboard upspring, but self.view do not upspring?" 对于您的情况“ [sendTextField成为FirstResponder]时,键盘出现问题,但self.view不会出现问题吗?”
You can manage textfield within scrollview or tableview with keyboard appearance. 您可以使用键盘外观在滚动视图或表视图中管理文本字段。
TPKeyboardAvoiding TPKeyboardAvoiding
Hope this might help you. 希望这对您有帮助。
If you don't want to use 3rd party SDK you can use observer and manage UIView frame programatically like this 如果您不想使用第三方SDK,则可以使用观察者并像这样以编程方式管理UIView框架
- (void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillBeHidden:) name:UIKeyboardWillHideNotification object:nil];
}
- (void)keyboardWillShow:(NSNotification*)aNotification {
[UIView animateWithDuration:0.25 animations:^
{
CGRect newFrame = [customView frame];
newFrame.origin.y -= [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue].size.height; // Adjust your tableview position by taking keyboard height
[tableView setFrame:newFrame];
}completion:^(BOOL finished)
{
}];
}
- (void)keyboardWillBeHidden:(NSNotification*)aNotification {
[UIView animateWithDuration:0.25 animations:^
{
CGRect newFrame = [customView frame];
newFrame.origin.y += [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue].size.height; // // Adjust your tableview position
[tableView setFrame:newFrame];
}completion:^(BOOL finished)
{
}];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[self.view endEditing:YES];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.