#import "TTKeyboardphobia.h"
- (void)viewDidLoad {
[super viewDidLoad];
self.keyboardphobia = [[TTKeyboardphobia alloc] init];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.keyboardphobia registerView:self.textView inScrollView:self.scrollView];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[self.keyboardphobia unregisterViews];
# Or, to unregister just a single view:
# [self.keyboardphobia unregisterView:self.textView];
}
您也可以在容器视图中嵌套输入视图,此时 TTKeyboardphobia 将将容器视图的框架对齐到键盘的顶部边缘。只需注册您的容器而不是直接注册输入视图即可
[self.keyboardphobia registerView:self.textViewContainer inScrollView:self.scrollView];
TTKeyboardphobia 会搜索视图层次结构以找到第一个响应者,所以您可以选择在多个容器视图中嵌套输入。
TTKeyboardphobia 通过 CocoaPods 提供。要安装它,请将以下行添加到您的 Podfile
pod "TTKeyboardphobia"
Ian Leitch, [email protected]
TTKeyboardphobia 在 BSD 许可下提供。有关更多信息,请参阅 LICENSE 文件。