KWMSearchFeedBackView.m 1.82 KB
Newer Older
houweibin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
//
//  KWMSearchFeedBackView.m
//  iCemarose
//
//  Created by 陈荣科 on 16/9/1.
//  Copyright © 2016年 kollway. All rights reserved.
//

#import "KWMSearchFeedBackView.h"

@implementation KWMSearchFeedBackView

- (instancetype)initWithFrame:(CGRect)frame{

    if (self = [super initWithFrame:frame]) {
        [self initContentView];
    }
    return self;
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
    if (self = [super initWithCoder:aDecoder]) {
        [self initContentView];
    }
    return self;
}

- (void)initContentView{
    [[NSBundle mainBundle] loadNibNamed:@"KWMSearchFeedBackView" owner:self options:nil];
    
    [self addSubview:self.vContent];
    self.lbGoodsNum.hidden = YES;
}
- (IBAction)onClickSearchBtn:(id)sender {
    if ([self.delegate respondsToSelector:@selector(kwm_searchGoods)]) {
        [self.delegate kwm_searchGoods];
    }
}

- (IBAction)onClickCancelBtn:(id)sender {
    if ([self.delegate respondsToSelector:@selector(kwm_cancelSearch)]) {
        [self.delegate kwm_cancelSearch];
    }
}

houweibin committed
47 48 49 50 51 52
- (void)layoutSubviews
{
    [super layoutSubviews];
    self.vContent.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
}

houweibin committed
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
#pragma mark -- UITextFieldDelegate
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    NSString *string = textField.text;
    string = [string stringByReplacingOccurrencesOfString:@" " withString:@""];
    if (string.length == 0) {
        return NO;
    }
    [textField resignFirstResponder];
    if ([self.delegate respondsToSelector:@selector(kwm_tfReturnSearchFinished:)]) {
        [self.delegate kwm_tfReturnSearchFinished:textField.text];
    }
    return YES;
}
- (void)textFieldDidBeginEditing:(UITextField *)textField{
    if ([self.delegate respondsToSelector:@selector(kwm_beginEditing)]) {
        [self.delegate kwm_beginEditing];
    }
}
@end