单军华
2018-03-28 f99cf1d5cc50407394501853be06cb39f38a092c
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
//
//  HotelAccountCell.m
//  istanbul
//
//  Created by WindShan on 2017/6/16.
//  Copyright © 2017年 WindShan. All rights reserved.
//
 
#import "HotelDeviceCell.h"
#import "GloriaLabel.h"
#import "UpdateHotelAccountPage.h"
 
@interface HotelDeviceCell()
{
    UIWebView *callWebview;
}
 
@property (nonatomic, strong)     GloriaLabel * devicenameLabel;
@property (nonatomic, strong)     GloriaLabel * statusLabel;
@property (nonatomic, strong)     UIButton    * nicknameChangeBtn;
@property (nonatomic, strong)     UIButton    * deleteBtn;
@property (nonatomic, strong)     UIImageView    * imageTag;
@end
 
@implementation HotelDeviceCell
 
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
 
- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.devicenameLabel.frame = CGRectMake(20, 20, SCREEN_WIDTH/2, 40);
    self.statusLabel.frame = CGRectMake(20+SCREEN_WIDTH/2, 20, SCREEN_WIDTH/3, 40);
 
    self.imageTag.frame = CGRectMake(20+SCREEN_WIDTH/2-30, 28, 24, 24);
    self.nicknameChangeBtn.frame = CGRectMake(SCREEN_WIDTH-30-20, 5, 30, 30);
    self.deleteBtn.frame         = CGRectMake(SCREEN_WIDTH-30-20, 45, 30, 30);
}
 
- (UIImageView *)imageTag
{
    if (!_imageTag)
    {
        _imageTag = [[UIImageView alloc] initWithFrame:CGRectMake(10, 0, SCREEN_WIDTH-20, 60)];
        [self.contentView addSubview:_imageTag];
    }
    
    return _imageTag;
}
 
-(UIButton*)deleteBtn
{
    if(!_deleteBtn)
    {
        _deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _deleteBtn.frame = CGRectMake(0, SCREEN_HEIGHT-100, 118, 30);
        [_deleteBtn setBackgroundImage:[UIImage imageNamed:@"icon_shanchu" ] forState:UIControlStateNormal];
        [_deleteBtn addTarget:self action:@selector(deleteAction) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:_deleteBtn];
    }
    
    return _deleteBtn;
}
 
-(void)deleteAction
{
    if ( _delegate && [_delegate respondsToSelector:@selector(updateDeviceSection:)])
    {
        self.model.cmd = 2;
        [_delegate updateDeviceSection:self.model];
    }
}
 
-(UIButton*)nicknameChangeBtn
{
    if(!_nicknameChangeBtn)
    {
        _nicknameChangeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _nicknameChangeBtn.frame = CGRectMake(0, SCREEN_HEIGHT-100, 118, 30);
        [_nicknameChangeBtn setBackgroundImage:[UIImage imageNamed:@"icon_bianji" ] forState:UIControlStateNormal];
        [_nicknameChangeBtn addTarget:self action:@selector(changeAction) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:_nicknameChangeBtn];
    }
    
    return _nicknameChangeBtn;
}
 
-(void)changeAction
{
    if ( _delegate && [_delegate respondsToSelector:@selector(updateDeviceSection:)])
    {
        self.model.cmd = 1;
        [_delegate updateDeviceSection:self.model];
    }
}
 
- (GloriaLabel *) devicenameLabel
{
    if(!_devicenameLabel)
    {
        _devicenameLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(10+50+10+80, 28,150, 14)];
        _devicenameLabel.font = [UIFont systemFontOfSize:16];
        _devicenameLabel.textAlignment = UITextAlignmentLeft;
        _devicenameLabel.textColor = kUIColorFromRGB(0x5a5a5a);
        [self.contentView addSubview:_devicenameLabel];
    }
    
    return _devicenameLabel;
}
 
- (GloriaLabel *) statusLabel
{
    if(!_statusLabel)
    {
        _statusLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(10+50+10+80, 28,150, 14)];
        _statusLabel.font = [UIFont systemFontOfSize:16];
        _statusLabel.textAlignment = UITextAlignmentLeft;
        _statusLabel.textColor = kUIColorFromRGB(0x5a5a5a);
        [self.contentView addSubview:_statusLabel];
    }
    
    return _statusLabel;
}
 
- (void)setItemView:(DeviceSpareModel*)model
{
    self.model = model;
    
    [self.devicenameLabel setText:model.name];
    self.imageTag.image = [UIImage imageNamed:model.status == 0?@"spare1":@"spare2"];
    [self.statusLabel setText:model.status == 0?@"闲置":@"使用"];
}
 
@end