不同模式的选择
This commit is contained in:
+12
-3
@@ -7,14 +7,23 @@
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "UIButton+ImageTitleStyle.h"
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class TimerTypeTableViewCell;
|
||||
@protocol TimerTypeTableViewCellDelegate <NSObject>
|
||||
|
||||
-(void)clickCell:(TimerTypeTableViewCell*)cell button:(UIButton*)button timerType:(NSInteger*)type;
|
||||
|
||||
@end
|
||||
@interface TimerTypeTableViewCell : UITableViewCell
|
||||
@property (weak, nonatomic) IBOutlet UIButton *timerbtn;
|
||||
@property (weak, nonatomic) IBOutlet UIButton *recoverybtn;
|
||||
@property (weak, nonatomic) IBOutlet UIButton *cyclebtn;
|
||||
@property (strong, nonatomic) UIButton *timerbtn;
|
||||
@property (strong, nonatomic) UIButton *recoverybtn;
|
||||
@property (strong, nonatomic) UIButton *cyclebtn;
|
||||
@property (nonatomic, strong) UIImageView *backImageView;
|
||||
@property (nonatomic, weak) id <TimerTypeTableViewCellDelegate>delegate;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
||||
+69
-8
@@ -10,16 +10,58 @@
|
||||
|
||||
@implementation TimerTypeTableViewCell
|
||||
|
||||
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
|
||||
{
|
||||
self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
||||
if (self)
|
||||
{
|
||||
|
||||
UIImageView*imageView=[[UIImageView alloc]init];
|
||||
imageView.image=[UIImage imageNamed:@"ifishSetCell_back"];
|
||||
self.backImageView=imageView;
|
||||
self.backgroundView=imageView;
|
||||
|
||||
UIFont*font=[UIFont systemFontOfSize:16];
|
||||
UIButton*timerBtn=[UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[timerBtn setTitle:@"定时模式" forState:UIControlStateNormal];
|
||||
[timerBtn setImage:[UIImage imageNamed:@"normalImage"] forState:UIControlStateNormal];
|
||||
[timerBtn setImage:[UIImage imageNamed:@"selectedImage"] forState:UIControlStateSelected];
|
||||
timerBtn.tag=1;
|
||||
timerBtn.titleLabel.font=font;
|
||||
[timerBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
|
||||
[timerBtn addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];
|
||||
self.timerbtn=timerBtn;
|
||||
|
||||
UIButton*cycleBtn=[UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[cycleBtn setTitle:@"循环模式" forState:UIControlStateNormal];
|
||||
[cycleBtn setImage:[UIImage imageNamed:@"normalImage"] forState:UIControlStateNormal];
|
||||
[cycleBtn setImage:[UIImage imageNamed:@"selectedImage"] forState:UIControlStateSelected];
|
||||
cycleBtn.titleLabel.font=font;
|
||||
[cycleBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
|
||||
cycleBtn.tag=2;
|
||||
[cycleBtn addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];
|
||||
self.cyclebtn=cycleBtn;
|
||||
|
||||
UIButton*recoveryBtn=[UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[recoveryBtn setTitle:@"自恢复模式" forState:UIControlStateNormal];
|
||||
[recoveryBtn setImage:[UIImage imageNamed:@"normalImage"] forState:UIControlStateNormal];
|
||||
[recoveryBtn setImage:[UIImage imageNamed:@"selectedImage"] forState:UIControlStateSelected];
|
||||
recoveryBtn.tag=3;
|
||||
recoveryBtn.titleLabel.font=font;
|
||||
[recoveryBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
|
||||
[recoveryBtn addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];
|
||||
self.recoverybtn=recoveryBtn;
|
||||
|
||||
[self.contentView addSubview:self.timerbtn];
|
||||
[self.contentView addSubview:self.cyclebtn];
|
||||
[self.contentView addSubview:self.recoverybtn];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
- (void)awakeFromNib {
|
||||
[super awakeFromNib];
|
||||
// Initialization code
|
||||
[self.timerbtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(0);
|
||||
make.bottom.mas_equalTo(0);
|
||||
make.width.mas_equalTo(120); }];
|
||||
self.timerbtn.titleEdgeInsets=UIEdgeInsetsMake(10, -90, 10, 0);
|
||||
self.timerbtn.titleLabel.font=[UIFont systemFontOfSize:15];
|
||||
|
||||
}
|
||||
|
||||
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
|
||||
@@ -27,5 +69,24 @@
|
||||
|
||||
// Configure the view for the selected state
|
||||
}
|
||||
|
||||
-(void)layoutSubviews
|
||||
{
|
||||
[super layoutSubviews];
|
||||
CGFloat width=self.frame.size.width/3.0;
|
||||
CGFloat height=self.frame.size.height;
|
||||
self.timerbtn.frame=CGRectMake(0, 0, width, height);
|
||||
self.cyclebtn.frame=CGRectMake(width, 0, width, height);
|
||||
self.recoverybtn.frame=CGRectMake(width*2, 0, width, height);
|
||||
[self.timerbtn setButtonImageTitleStyle:ButtonImageTitleStyleRight padding:0];
|
||||
[self.cyclebtn setButtonImageTitleStyle:ButtonImageTitleStyleRight padding:0];
|
||||
[self.recoverybtn setButtonImageTitleStyle:ButtonImageTitleStyleRight padding:0];
|
||||
|
||||
}
|
||||
-(void)btnClicked:(UIButton*)button
|
||||
{
|
||||
if ([self.delegate respondsToSelector:@selector(clickCell:button:timerType:)])
|
||||
{
|
||||
[self.delegate clickCell:self button:button timerType:button.tag];
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
-31
@@ -16,40 +16,9 @@
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="N2e-hF-SlL" userLabel="timerbtn">
|
||||
<rect key="frame" x="10" y="2" width="136" height="35"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<state key="normal" title="Button"/>
|
||||
<buttonConfiguration key="configuration" style="plain" image="selectedImage" title="定时模式" titleAlignment="automatic"/>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="xbU-qP-hXX" userLabel="recoverybtn">
|
||||
<rect key="frame" x="203" y="-2" width="136" height="35"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<state key="normal" title="Button"/>
|
||||
<buttonConfiguration key="configuration" style="plain" image="selectedImage" title="自恢复模式" titleAlignment="automatic"/>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="yqV-t4-x09" userLabel="cyclebtn">
|
||||
<rect key="frame" x="113" y="5" width="136" height="35"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<state key="normal" title="Button"/>
|
||||
<buttonConfiguration key="configuration" style="plain" image="selectedImage" title="循环模式" titleAlignment="automatic"/>
|
||||
</button>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
<viewLayoutGuide key="safeArea" id="aW0-zy-SZf"/>
|
||||
<connections>
|
||||
<outlet property="cyclebtn" destination="yqV-t4-x09" id="Ptm-mX-wAk"/>
|
||||
<outlet property="recoverybtn" destination="xbU-qP-hXX" id="AG5-Cy-9Th"/>
|
||||
<outlet property="timerbtn" destination="N2e-hF-SlL" id="6Nb-dL-mwl"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="137.68115942028987" y="68.973214285714278"/>
|
||||
</tableViewCell>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="selectedImage" width="30" height="30"/>
|
||||
</resources>
|
||||
</document>
|
||||
|
||||
+3
@@ -9,6 +9,8 @@
|
||||
#import "FatherController.h"
|
||||
#import "IfishDeviceInfo.h"
|
||||
#include "xuanduo3fModel.h"
|
||||
#import "ReadTimerModel.h"
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@@ -19,6 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property (nonatomic,strong) UIActivityIndicatorView*indicatorView;
|
||||
@property (nonatomic ,strong) id dataModel;
|
||||
@property(nonatomic,strong) DeviceModel* currentdevice;
|
||||
@property (nonatomic, strong) ReadTimerModel *readMode;
|
||||
|
||||
- (void)refreshWithData:(id)model;
|
||||
|
||||
|
||||
+9
@@ -55,4 +55,13 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@end
|
||||
|
||||
@interface XuanduoRecoveryModel : NSObject
|
||||
|
||||
/// 灯的序号
|
||||
@property (nonatomic, strong) NSString *lightNumber;
|
||||
@property (nonatomic, strong) NSString *lastTime;
|
||||
@property (nonatomic, strong) NSString *gapTime;
|
||||
@property (nonatomic, strong) NSString *status;
|
||||
|
||||
@end
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
+2
-1
@@ -9,6 +9,7 @@
|
||||
#import "FatherController.h"
|
||||
#import "IfishDeviceInfo.h"
|
||||
#include "xuanduo3fModel.h"
|
||||
#import "ReadTimerModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@@ -19,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property (nonatomic,strong) UIActivityIndicatorView*indicatorView;
|
||||
@property (nonatomic ,strong) id dataModel;
|
||||
@property(nonatomic,strong) DeviceModel* currentdevice;
|
||||
|
||||
@property (nonatomic, strong) ReadTimerModel *readMode;
|
||||
- (void)refreshWithData:(id)model;
|
||||
|
||||
@end
|
||||
|
||||
+12
-3
@@ -41,7 +41,7 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
|
||||
|
||||
|
||||
|
||||
@interface XuanduoTimerSettingViewController ()<IfishCommuniteDelegate>
|
||||
@interface XuanduoTimerSettingViewController ()<IfishCommuniteDelegate,TimerTypeTableViewCellDelegate>
|
||||
@property(nonatomic,strong) setRemindWaterModel *waterInfmodel;
|
||||
@property(nonatomic,strong) Xuanduo2TimerModel *timerModel;
|
||||
@property(nonatomic,strong) XuanduoCycleModel *cycleModel;
|
||||
@@ -154,10 +154,14 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
|
||||
[self.tableView registerNib:[UINib nibWithNibName:temperatureCellid bundle:nil] forCellReuseIdentifier:temperatureCellid];
|
||||
[self.tableView registerNib:[UINib nibWithNibName:changeWaterCellid bundle:nil] forCellReuseIdentifier:changeWaterCellid];
|
||||
[self.tableView registerNib:[UINib nibWithNibName:addCellid bundle:nil] forCellReuseIdentifier:addCellid];
|
||||
[self.tableView registerNib:[UINib nibWithNibName:timerTypeFlag bundle:nil] forCellReuseIdentifier:timerTypeFlag];
|
||||
//[self.tableView registerNib:[UINib nibWithNibName:timerTypeFlag bundle:nil] forCellReuseIdentifier:timerTypeFlag];
|
||||
[self.tableView registerNib:[UINib nibWithNibName:setTimerflag bundle:nil] forCellReuseIdentifier:setTimerflag];
|
||||
}
|
||||
|
||||
-(void)clickCell:(TimerTypeTableViewCell *)cell button:(UIButton *)button timerType:(NSInteger *)type
|
||||
{
|
||||
|
||||
}
|
||||
#pragma mark - Table view data source
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
||||
@@ -322,7 +326,10 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
|
||||
NSArray *dataArr = [self.timeDic objectForKey:_titieArr[indexPath.section-2]];
|
||||
BOOL havePlus = [dataArr containsObject:plusflag];
|
||||
if (havePlus && (indexPath.row == dataArr.count-1)) {
|
||||
TimerTypeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:timerTypeFlag forIndexPath:indexPath];
|
||||
TimerTypeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:timerTypeFlag];
|
||||
if (!cell) {
|
||||
cell=[[TimerTypeTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:timerTypeFlag];
|
||||
}
|
||||
|
||||
return cell;
|
||||
}else {
|
||||
@@ -589,6 +596,7 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
|
||||
_selectSection = btn.tag - kBtnTag;
|
||||
ReadTimerModel *readModel = [[ReadTimerModel alloc] init];
|
||||
//杀菌不定时
|
||||
readModel.selectorName=_titieArr[_selectSection - 2];
|
||||
if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F]&&(_selectSection - 2)==2)
|
||||
{
|
||||
readModel.functionCode=@"19";//读取
|
||||
@@ -637,6 +645,7 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
|
||||
NSString*readString=[NSString stringWithFormat:@"%@%@%@",readModel.description,readModel.selectorNumber,readModel.crc16str];
|
||||
NSData*readData=[dataContorl stringToHexData:readString];
|
||||
[[Socketsingleton sharedInstance] soketWriteData:readData];
|
||||
self.readMode=readModel;
|
||||
[_indicatorView startAnimating];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user