iOS:I 对textview有需求成为第一响应者

iOS:I have a requirement with textview become first responder

[sendTextField becomeFirstResponder]时,keyboardupspringself.view也会出现

我有一个要求,[sendTextField becomeFirstResponder]的时候,keyboard出现,但是self.view不出现?

编辑:为了更清楚我的问题,我添加了一张图片:

我的要求是: tableview 不弹出,textview's back 弹出 keyboard

编辑:对于 Ajay Gabani 的回答,我在 ipnone-5s 中使用 TPKeyboardAvoiding 的示例进行了测试,我发现了这一点,tableView 也 upspring keyboard,图片会显示:

来源状态:

tableview upspring:

抱歉,我无法对您的问题发表评论。

针对你的情况"when [sendTextField becomeFirstResponder], the keyboard upspring, but self.view do not upspring?"

您可以在带有键盘外观的滚动视图或表格视图中管理文本字段。

TPKeyboardAvoiding

希望这对您有所帮助。

如果您不想使用第 3 方 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];
}