2 Star 6 Fork 1

ShownBie / SXKeyboardViewControl

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
contribute
Sync branch
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README
MIT

SXKeyboardViewControl

自动控制有键盘时候界面的升起和落下

自动控制viewController的textView和textField被键盘遮挡问题 引入.h即可

适应各种界面view,scrollView,tabView等

只需一步,引入头文件即可 import "UIViewController+SXKeyboardViewControl.h"


示例效果图

img

img

img

//最近更新

推荐的使用方式:

在父类里面创建,并设置一个开关

SuperClass.h

//有键盘-设置Yes会调整view
@property (nonatomic,assign) BOOL isKeyboard;//默认No

SuperClass.m

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    if (_isKeyboard) {
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onKeyboardNotification:) name:UIKeyboardWillChangeFrameNotification object:nil];
    }
}

- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
    if (_isKeyboard) {
        [self.view endEditing:YES];
        [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
        [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
    }
}

之前方案弊端:

  1. 在分类重写系统方法, 可能会带来其他不必要的麻烦
  2. 所有的VC都进行监听, 增加了系统开销
MIT License Copyright (c) 2017 xiaoR Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

自动控制viewController的textView和textField被键盘遮挡问题,引入.h即可 expand collapse
Objective-C
MIT
Cancel

Releases

No release

Contributors

All

Activities

Load More
can not load any more
Objective-C
1
https://gitee.com/poos/SXKeyboardViewControl.git
git@gitee.com:poos/SXKeyboardViewControl.git
poos
SXKeyboardViewControl
SXKeyboardViewControl
master

Search