简洁且功能强大的 scrollView,负责处理键盘下方内容移动。
将 RDVKeyboardAvoidingScrollView.h
和 RDVKeyboardAvoidingScrollView.m
放入您的项目中。如果您未启用 ARC,您需要在 .m
源文件上设置 -fobjc-arc
编译器标志。对于与 UIViewController
类一起使用,请将 RDVKeyboardAvoidingScrollView.h
包含在您的 UIViewController
子类中,并设置其视图为此类的一个实例。如果您正在使用 xib 文件,请在 Identity Inspector
中设置视图的类。
将视图控制器视图初始化为 RDVKeyboardAvoiding
的实例
- (void)loadView {
CGRect applicationFrame = [[UIScreen mainScreen] applicationFrame];
RDVKeyboardAvoidingScrollView *scrollView = [[RDVKeyboardAvoidingScrollView alloc] initWithFrame:applicationFrame];
[scrollView setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
// code...
self.view = scrollView;
}
RDVKeyboardAvoiding 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。