IOS TextFile键盘不遮挡 + 下拉隐藏键盘
2014-03-24 16:37
766 查看
self.title =
@"DAKeyboardControl";
self.view.backgroundColor = [UIColor
lightGrayColor];
UITableView *tableView = [[UITableView
alloc] initWithFrame:CGRectMake(0.0f,
0.0f,
self.view.bounds.size.width,
self.view.bounds.size.height -
40.0f)];
tableView.autoresizingMask =
UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view
addSubview:tableView];
UIToolbar *toolBar = [[UIToolbar
alloc] initWithFrame:CGRectMake(0.0f,
self.view.bounds.size.height -
40.0f,
self.view.bounds.size.width,
40.0f)];
toolBar.autoresizingMask =
UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth;
[self.view
addSubview:toolBar];
UITextField *textField = [[UITextField
alloc] initWithFrame:CGRectMake(10.0f,
6.0f,
toolBar.bounds.size.width
- 20.0f - 68.0f,
30.0f)];
textField.borderStyle =
UITextBorderStyleRoundedRect;
textField.autoresizingMask =
UIViewAutoresizingFlexibleWidth;
[toolBar
addSubview:textField];
UIButton *sendButton = [UIButton
buttonWithType:UIButtonTypeRoundedRect];
sendButton.autoresizingMask =
UIViewAutoresizingFlexibleLeftMargin;
[sendButton setTitle:@"Send"
forState:UIControlStateNormal];
sendButton.frame =
CGRectMake(toolBar.bounds.size.width -
68.0f,
6.0f,
58.0f,
29.0f);
[toolBar
addSubview:sendButton];
self.view.keyboardTriggerOffset = toolBar.bounds.size.height;
[self.view
addKeyboardPanningWithActionHandler:^(CGRect keyboardFrameInView)
{
/*
Try not to call "self" inside this block (retain cycle).
But if you do, make sure to remove DAKeyboardControl
when you are done with the view controller by calling:
[self.view removeKeyboardControl];
*/
CGRect toolBarFrame = toolBar.frame;
toolBarFrame.origin.y = keyboardFrameInView.origin.y
- toolBarFrame.size.height;
toolBar.frame = toolBarFrame;
CGRect tableViewFrame = tableView.frame;
tableViewFrame.size.height = toolBarFrame.origin.y;
tableView.frame = tableViewFrame;
}];
@"DAKeyboardControl";
self.view.backgroundColor = [UIColor
lightGrayColor];
UITableView *tableView = [[UITableView
alloc] initWithFrame:CGRectMake(0.0f,
0.0f,
self.view.bounds.size.width,
self.view.bounds.size.height -
40.0f)];
tableView.autoresizingMask =
UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view
addSubview:tableView];
UIToolbar *toolBar = [[UIToolbar
alloc] initWithFrame:CGRectMake(0.0f,
self.view.bounds.size.height -
40.0f,
self.view.bounds.size.width,
40.0f)];
toolBar.autoresizingMask =
UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth;
[self.view
addSubview:toolBar];
UITextField *textField = [[UITextField
alloc] initWithFrame:CGRectMake(10.0f,
6.0f,
toolBar.bounds.size.width
- 20.0f - 68.0f,
30.0f)];
textField.borderStyle =
UITextBorderStyleRoundedRect;
textField.autoresizingMask =
UIViewAutoresizingFlexibleWidth;
[toolBar
addSubview:textField];
UIButton *sendButton = [UIButton
buttonWithType:UIButtonTypeRoundedRect];
sendButton.autoresizingMask =
UIViewAutoresizingFlexibleLeftMargin;
[sendButton setTitle:@"Send"
forState:UIControlStateNormal];
sendButton.frame =
CGRectMake(toolBar.bounds.size.width -
68.0f,
6.0f,
58.0f,
29.0f);
[toolBar
addSubview:sendButton];
self.view.keyboardTriggerOffset = toolBar.bounds.size.height;
[self.view
addKeyboardPanningWithActionHandler:^(CGRect keyboardFrameInView)
{
/*
Try not to call "self" inside this block (retain cycle).
But if you do, make sure to remove DAKeyboardControl
when you are done with the view controller by calling:
[self.view removeKeyboardControl];
*/
CGRect toolBarFrame = toolBar.frame;
toolBarFrame.origin.y = keyboardFrameInView.origin.y
- toolBarFrame.size.height;
toolBar.frame = toolBarFrame;
CGRect tableViewFrame = tableView.frame;
tableViewFrame.size.height = toolBarFrame.origin.y;
tableView.frame = tableViewFrame;
}];
相关文章推荐
- iOS隐藏键盘实现和针对键盘遮挡输入控件的解决
- iOS键盘隐藏,下一个textField,键盘控制第三方好用框架IQKeyboardManager
- iOS 隐藏键盘,输入法,防止遮挡输入框
- iOS开发 键盘遮挡输入框(TextView、TextField)问题
- iOS TextField 弹出键盘时实现view整体上移下移:防止弹出键盘遮挡输入框
- [ios]TableView的Cell中有Textfield时放置键盘遮挡输入框
- IOS TextFiled与TextView 键盘的收起以及处理键盘遮挡
- ios自定义TextView,实时监控输入字数的改变,计数以及超出时键盘自动隐藏
- [iOS textfile一行代码 键盘消失]
- 猫猫学iOS之iOS键盘隐藏,下一个textField,键盘控制第三方好用框架IQKeyboardManager
- CCTextFieldTTF ios按return 隐藏键盘
- iOS 处理键盘遮挡TextField、TextView问题
- ios菜鸟之路:textfield隐藏键盘以及点击背景取消键盘
- iOS TextFiled、TextView 关于键盘的收起以及处理键盘遮挡
- (iOS)关于键盘遮挡textfield问题
- iOS模拟器,点击textfield为什么不弹出软键盘
- IOS 键盘遮挡处理
- ios 开发 中文和英文状态下 键盘的变化 textview 对键盘的适应
- iOS 关于隐藏键盘那些事儿
- iOS实现scrollview上拉显示Navbar下拉隐藏功能详解