Latest 0.3.5
Homepage https://github.com/Magora-IOS/MAGComfortTextInput
License MIT
Platforms ios 8.0
Dependencies MAGMatveevReusable
Authors

It makes using of UITextField, UITextView much easier by taking up keyboard’s displaying behaviour

Supported parent views:

  • UIView
  • UIScrollView (and subclasses, i.e. UITableView)

Possibilities:

  • 1 Centering of active UITextField / UITextView (aka "InputField") on free space between top of screen and top of appeared keyboard.
  • 2 Dismiss by click on empty area
  • 3 Action by Next / Done button’s pressing
  • 4 Easy for addition customization

MAGComfortTextInput

WARNING

For testing on iOS Simulator you have to enable displaying of keyboard. For doing this open iOS Simulator -> Hardware -> Keyboard -> Connect Hardware Keyboard / Toggle software keyboard. (here CMD + K / CMD + SHIFT + K combinations)

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

MAGComfortTextInput works on iOS 7+ (may be 6+, I’m not sure).

Installation

MAGPdfGenerator is available through CocoaPods. To install
it, simply add the following line to your Podfile and run pod install:

pod 'MAGComfortTextInput'

Usage

You should prepare MAGKeyboardInfo before [self.window makeKeyAndVisible] in AppDelegate.m. If you create your windows manually, then do this after creation of this. For example:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
[[MAGKeyboardInfo sharedInstance] prepareKeyboardWithMainWindow:self.window];
[self.window makeKeyAndVisible];
...
}

Else, if you use launch screen, then call this method at first after your window’s creation!

So, for example, you have 3 UITextField and 3 UITextView in UIView of your UIViewController:

@property (weak, nonatomic) IBOutlet UITextField *tf1;
@property (weak, nonatomic) IBOutlet UITextField *tf2;
@property (weak, nonatomic) IBOutlet UITextField *tf3;
@property (weak, nonatomic) IBOutlet UITextView *tv1;
@property (weak, nonatomic) IBOutlet UITextView *tv2;
@property (weak, nonatomic) IBOutlet UITextView *tv3;

@property (strong, nonatomic) MAGViewComfortTextInput *comfortTextInput;

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

    [self configureTextFieldsForConvinientUsing];
    [self.tf1 becomeFirstResponder];
}

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

    [self.comfortTextInput resetWithResignFirstResponder];
}

- (MAGViewComfortTextInput *)configureTextFieldsForConvinientUsing {
    if (_comfortTextInput) {
        return _comfortTextInput;
    }

    _comfortTextInput = [[MAGViewComfortTextInput alloc] initWithOrderedTextInputControls:@[self.tf1,self.tv1,self.tf2,self.tv2,self.tf3,self.tv3 ] withOwnerView:self.view];
    _comfortTextInput.textInputControlDidEndEditingBlock = ^(UIView *textInputControl) {
        NSLog(@"DO SOMETHING");
    };
    _comfortTextInput.lastTextInputControlDidEndEditingBlock = ^(UIView *textInputControl) {
        NSLog(@"DO SOMETHING ON FINISH");
    };
    return _comfortTextInput;
}

If, for example, you have 3 UITextField and 3 UITextView in UIScrollView (or UITableView) of your UIViewController, then change initialization code on the next:

- (MAGViewComfortTextInput *)configureTextFieldsForConvinientUsing {
    if (_comfortTextInput) {
        return _comfortTextInput;
    }

    _comfortTextInput = [[MAGScrollViewComfortTextInput alloc] initWithOrderedTextInputControls:@[self.tf1,self.tv1,self.tf2,self.tv2,self.tf3,self.tv3 ] withOwnerView:self.view withScrollViewInsideOwnerViewWhereTextFieldsLocated:self.scrollView];
    _comfortTextInput.textInputControlDidEndEditingBlock = ^(UIView *textInputControl) {
        NSLog(@"DO SOMETHING");
    };
    _comfortTextInput.lastTextInputControlDidEndEditingBlock = ^(UIView *textInputControl) {
        NSLog(@"DO SOMETHING ON FINISH");
    };
    return _comfortTextInput;
}

KNOWN ISSUES

Not use textInputControls, which located in UITableView.tableHeaderView and UITableView.tableFooterView bcs perhaps due hidden logics of this views (autolayout logics) focusing of it works wrong…

Author

Denis Matveev, [email protected]

License

See the LICENSE file for more info.

Latest podspec

{
    "name": "MAGComfortTextInput",
    "version": "0.3.5",
    "summary": "Making an input into UITextFields/UITextViews convinient",
    "description": "Class for centering of focused UITextFields/UITextViews on free space of screen",
    "homepage": "https://github.com/Magora-IOS/MAGComfortTextInput",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Denis Matveev": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Magora-IOS/MAGComfortTextInput.git",
        "tag": "0.3.5"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "MAGComfortTextInput/Classes/**/*",
    "dependencies": {
        "MAGMatveevReusable": [
            "~> 0.3.4"
        ]
    }
}

Pin It on Pinterest

Share This