New file |
| | |
| | | /************************************************************ |
| | | * * Hyphenate CONFIDENTIAL |
| | | * __________________ |
| | | * Copyright (C) 2016 Hyphenate Inc. All rights reserved. |
| | | * |
| | | * NOTICE: All information contained herein is, and remains |
| | | * the property of Hyphenate Inc. |
| | | * Dissemination of this information or reproduction of this material |
| | | * is strictly forbidden unless prior written permission is obtained |
| | | * from Hyphenate Inc. |
| | | */ |
| | | |
| | | #import "EaseViewController.h" |
| | | |
| | | @interface EaseViewController () |
| | | |
| | | @property (strong, nonatomic) UITapGestureRecognizer *tapRecognizer; |
| | | |
| | | @end |
| | | |
| | | @implementation EaseViewController |
| | | |
| | | - (void)viewDidLoad { |
| | | [super viewDidLoad]; |
| | | // Do any additional setup after loading the view. |
| | | if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)]){ |
| | | [self setEdgesForExtendedLayout:UIRectEdgeNone]; |
| | | } |
| | | |
| | | _tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapViewAction:)]; |
| | | [self.view addGestureRecognizer:_tapRecognizer]; |
| | | _endEditingWhenTap = YES; |
| | | } |
| | | |
| | | - (void)didReceiveMemoryWarning { |
| | | [super didReceiveMemoryWarning]; |
| | | // Dispose of any resources that can be recreated. |
| | | } |
| | | |
| | | #pragma mark - setter |
| | | |
| | | - (void)setEndEditingWhenTap:(BOOL)endEditingWhenTap |
| | | { |
| | | if (_endEditingWhenTap != endEditingWhenTap) { |
| | | _endEditingWhenTap = endEditingWhenTap; |
| | | |
| | | if (_endEditingWhenTap) { |
| | | [self.view addGestureRecognizer:self.tapRecognizer]; |
| | | } |
| | | else{ |
| | | [self.view removeGestureRecognizer:self.tapRecognizer]; |
| | | } |
| | | } |
| | | } |
| | | |
| | | #pragma mark - action |
| | | |
| | | - (void)tapViewAction:(UITapGestureRecognizer *)tapRecognizer |
| | | { |
| | | if (tapRecognizer.state == UIGestureRecognizerStateEnded) { |
| | | [self.view endEditing:YES]; |
| | | } |
| | | } |
| | | |
| | | @end |