Initial commit
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// NoneControlCenterViewController.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 16/4/18.
|
||||
// Copyright © 2016年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import "CenterViewController.h"
|
||||
|
||||
@interface NoneControlCenterViewController : CenterViewController
|
||||
|
||||
@property(nonatomic,strong)UIImageView*noneControlImgView;
|
||||
|
||||
@end
|
||||
+188
@@ -0,0 +1,188 @@
|
||||
//
|
||||
// NoneControlCenterViewController.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 16/4/18.
|
||||
// Copyright © 2016年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NoneControlCenterViewController.h"
|
||||
#import "NoneControlNonetimerViewController.h"
|
||||
|
||||
@interface NoneControlCenterViewController ()
|
||||
|
||||
@property(nonatomic,strong)NoneControlNonetimerViewController*noncontrolnonetimerVC;
|
||||
@property(nonatomic,strong)ZeroControlBackmsgModel*zeroControlbackModel;
|
||||
@end
|
||||
|
||||
@implementation NoneControlCenterViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
//主界面按钮事件分离
|
||||
[Socketsingleton sharedInstance].communiteDelegate=self;
|
||||
_zeroControlbackModel= [[ZeroControlBackmsgModel alloc] init];
|
||||
[self.SetTimeButton addTarget:self action:@selector(NoneControlSetBtnAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.setbackBtn addTarget:self action:@selector(NoneControlSetBtnAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
UITapGestureRecognizer*tapgestureRecognizer=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(NoneCenterViewSetTap)];
|
||||
[self.setImag addGestureRecognizer:tapgestureRecognizer];
|
||||
|
||||
UITapGestureRecognizer*tapGesture=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(NoneControlViewclockViewClick)];
|
||||
self.clockView.userInteractionEnabled=YES;
|
||||
[self.clockView addGestureRecognizer:tapGesture];
|
||||
|
||||
//[self initNoneControlView];
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(void)initNoneControlView{
|
||||
|
||||
// // AppDelegate*lauotDelegate=(AppDelegate*)[[UIApplication sharedApplication]delegate];
|
||||
// UIImage*mainImage=[UIImage imageNamed:@"nc_backImg"];
|
||||
// self.noneControlImgView=[[UIImageView alloc]initWithImage:mainImage];
|
||||
// self.noneControlImgView.frame=CGRectMake(0, 180, kScreenSize.width, kScreenSize.height-64);
|
||||
// // [self.tableView addSubview:self.noneControlImgView];
|
||||
//
|
||||
//// self.temperature.frame=CGRectMake(70*lauotDelegate.autoSizeScaleX, 240*lauotDelegate.autoSizeScaleY, ((kScreenSize.width/8)*2 + 20 + 50 + 25)*lauotDelegate.autoSizeScaleX, (kScreenSize.width/8)*2*lauotDelegate.autoSizeScaleY);
|
||||
//// self.temperaturebackImg.frame=CGRectMake(10, kScreenSize.height/2-80*lauotDelegate.autoSizeScaleY, kScreenSize.width-10*2, (kScreenSize.width-10*2)*0.638f);
|
||||
//// self.dulabel.frame=CGRectMake(245*lauotDelegate.autoSizeScaleX,240*lauotDelegate.autoSizeScaleY,50*lauotDelegate.autoSizeScaleX, 40*lauotDelegate.autoSizeScaleY);
|
||||
//// [self.tableView bringSubviewToFront:self.dulabel];
|
||||
//
|
||||
//
|
||||
//
|
||||
// // [self.tableView addSubview:self.dulabel];
|
||||
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - 两控界面设置btn点击事件
|
||||
|
||||
-(void)NoneControlSetBtnAction:(UIButton*)btn{
|
||||
//主界面UI已调整 v2.0 后方法 已废弃
|
||||
|
||||
NSLog(@"点击了设置");
|
||||
[self selfPushSate];
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - 设置图片点击事件
|
||||
|
||||
-(void)NoneCenterViewSetTap{
|
||||
|
||||
[self selfPushSate];
|
||||
}
|
||||
|
||||
#pragma mark - 锁屏图片点击事件
|
||||
|
||||
-(void)NoneControlViewclockViewClick{
|
||||
|
||||
[self selfPushSate];
|
||||
|
||||
}
|
||||
|
||||
-(void)selfPushSate{
|
||||
|
||||
ZeroControlBackmsgModel*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"DeviceBackZeroControlInfo"];
|
||||
|
||||
if (backmodel) {
|
||||
|
||||
[self pushSetTimeVC];
|
||||
|
||||
}else{
|
||||
|
||||
[self.indicatorView stopAnimating];
|
||||
[self deviceNotOnlineState];
|
||||
[self showLableAction:@"设备已离线"];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - 转跳设置界面
|
||||
|
||||
-(void)pushSetTimeVC{
|
||||
|
||||
_noncontrolnonetimerVC=[[NoneControlNonetimerViewController alloc]init];
|
||||
|
||||
_noncontrolnonetimerVC.currentdevice=self.currentDevice;
|
||||
|
||||
[self.navigationController pushViewController:_noncontrolnonetimerVC animated:YES];
|
||||
// self.navigationBarHidden=NO;
|
||||
|
||||
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
|
||||
[super didReceiveMemoryWarning];
|
||||
|
||||
}
|
||||
#pragma mark 登陆成功后收到服务端的回执之后,调用的代理方法
|
||||
-(void)socketDidGetBackmsgData:(NSData *)data onsoket:(AsyncSocket *)sock{
|
||||
|
||||
NSLog(@"NoneControlView收到服务器的回执--->%@",data);
|
||||
|
||||
|
||||
|
||||
//NSString*string1=[dataContorl dataToHexString:data];
|
||||
//self.offlineLabel.hidden=YES;
|
||||
self.temperature.hidden=NO;
|
||||
//设备在线显示与设备离线相对应
|
||||
self.dulabel.hidden=NO;
|
||||
//设备在线显示与设备离线相对应 收到返回数据改变显示状态
|
||||
self.notOnLineLabel.hidden = YES;
|
||||
self.temperaturebackImg.hidden=NO;
|
||||
|
||||
[self.indicatorView stopAnimating];
|
||||
//[_HUD hide:YES];
|
||||
[self.myhud hidmyHud];
|
||||
|
||||
if (_noncontrolnonetimerVC.indicatorView) {
|
||||
[_noncontrolnonetimerVC.indicatorView stopAnimating];
|
||||
}
|
||||
|
||||
[DeviceCommunicateDataUnity readSoketbackMassageZeroControlData:data WithModel:_zeroControlbackModel];
|
||||
self.waringLabel.hidden=YES;
|
||||
self.clockView.hidden=YES;
|
||||
if ([_zeroControlbackModel.baojingSwitch isEqualToString:@"01"]) {
|
||||
|
||||
self.temperaturebackImg.hidden=NO;
|
||||
|
||||
}else{
|
||||
self.temperaturebackImg.hidden=YES;
|
||||
|
||||
}
|
||||
|
||||
//温度
|
||||
|
||||
[DeviceCommunicateDataUnity setZeroControlTemperaturelabel:self.temperature addTemperaturebackImg:self.temperaturebackImg addbubleImgeView:self.bubble WithBackData:data addWithBackMassageModel:_zeroControlbackModel addWithTableview:self.tableView];
|
||||
|
||||
//设置界面
|
||||
|
||||
_noncontrolnonetimerVC.timeArr=[DeviceCommunicateDataUnity refreshNoneControlSetViewWithBackMassageModel:_zeroControlbackModel];
|
||||
[_noncontrolnonetimerVC.tableView reloadData];
|
||||
|
||||
[self endRefreshing];
|
||||
|
||||
|
||||
}
|
||||
-(void)ifishDeviceLogInSuccees{
|
||||
self.isconnect=YES;
|
||||
NSLog(@"app登录成功");
|
||||
|
||||
}
|
||||
-(void)ifishDeviceLogInFail{
|
||||
|
||||
[self endRefreshing];
|
||||
[self.indicatorView stopAnimating];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self deviceNotOnlineState];//设备离线
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// NoneControlNonetimerViewController.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 16/3/8.
|
||||
// Copyright © 2016年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import "FatherController.h"
|
||||
#import "Socketsingleton.h"
|
||||
@interface NoneControlNonetimerViewController : FatherController
|
||||
{
|
||||
BOOL _isHidden;
|
||||
BOOL mySwitchIsOn;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@property(nonatomic,strong)NSArray*timeArr;
|
||||
|
||||
@property(nonatomic,strong)NSArray*titleArr;
|
||||
|
||||
|
||||
@property(nonatomic,strong)UIButton*mySwitchButton;
|
||||
|
||||
|
||||
@property(nonatomic)UIActivityIndicatorView*indicatorView;
|
||||
-(void)addAlertView;
|
||||
|
||||
@property(nonatomic)int percent;
|
||||
@property(nonatomic,strong) DeviceModel* currentdevice;
|
||||
@end
|
||||
+901
@@ -0,0 +1,901 @@
|
||||
//
|
||||
// NoneControlNonetimerViewController.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 16/3/8.
|
||||
// Copyright © 2016年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NoneControlNonetimerViewController.h"
|
||||
#import "SetTimeCell.h"
|
||||
#import "SecondSetTimeCell.h"
|
||||
#import "SetTimeModel.h"
|
||||
#import "SetSelectorTime.h"
|
||||
//#import "AsyncSocket.h"
|
||||
#import "setWaringTpModel.h"
|
||||
#import "appLogin.h"
|
||||
#import "workTypeModel.h"
|
||||
#import "SetSelectorTime.h"
|
||||
|
||||
#define TIME_TAG 300
|
||||
#import "MyPickerView.h"
|
||||
#import "searchDeviceModel.h"
|
||||
|
||||
#import "MydatePickerView.h"
|
||||
#define SET_CELL_TAG 2200
|
||||
#define MYSWITCH_TAG 3200
|
||||
#import "CenterViewController.h"
|
||||
#import "TimerSateModel.h"
|
||||
#import "TemperatureSetCell.h"
|
||||
#import "TemperatureSetModel.h"
|
||||
#import "ZeroControlBackmsgModel.h"
|
||||
#import "BrightnessCell.h"
|
||||
#import "GuiDengViewCell.h"
|
||||
#import "ChangeWaterCell.h"
|
||||
#import "GuidengKaiGuanModel.h"
|
||||
#import "BrightnessModel.h"
|
||||
#import "remindCyclePic.h"
|
||||
#import "setRemindWaterModel.h"
|
||||
#import "CreatErWeiMaController.h"
|
||||
@interface NoneControlNonetimerViewController ()
|
||||
{
|
||||
|
||||
MydatePickerView*_mydatepicView;
|
||||
MyPickerView* _mypicView;
|
||||
dispatch_queue_t _mainQueue;
|
||||
remindCyclePic*_remindPic;
|
||||
BOOL _huanshuiSwitchIsOn;
|
||||
}
|
||||
@property(nonatomic,strong)NSIndexPath*indexpath;
|
||||
|
||||
@property(nonatomic,copy)NSString*statString;
|
||||
@property(nonatomic,copy)NSString*endString;
|
||||
|
||||
@property(nonatomic,copy)NSString*nextChangeDateLabel;
|
||||
|
||||
@property(nonatomic,strong)setRemindWaterModel*waterInfmodel;
|
||||
|
||||
@end
|
||||
|
||||
@implementation NoneControlNonetimerViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
_waterInfmodel=[[setRemindWaterModel alloc]init];
|
||||
_mainQueue = dispatch_get_main_queue();
|
||||
self.navigationController.navigationBar.backItem.title=@"";
|
||||
[self addTitleViewWithTitle:@"设置"];
|
||||
[self initData];
|
||||
self.tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
|
||||
[self creatIndicatorView];
|
||||
|
||||
self.view.backgroundColor = COLOR_MIAN;
|
||||
self.tableView.backgroundColor = COLOR_MIAN;
|
||||
|
||||
// if ([self.currentdevice.isMaster isEqualToString:@"1"]) {
|
||||
// UIBarButtonItem*rightItem=[[UIBarButtonItem alloc]initWithTitle:@"分享设备" style: UIBarButtonItemStyleDone target:self action:@selector(noneItemClick)];
|
||||
// rightItem.tintColor=[UIColor whiteColor];
|
||||
// self.navigationItem.rightBarButtonItem=rightItem;
|
||||
// }
|
||||
//
|
||||
}
|
||||
-(void)noneItemClick{
|
||||
|
||||
CreatErWeiMaController*vc=[[CreatErWeiMaController alloc]init]
|
||||
;
|
||||
vc.erdevicemodel=self.currentdevice;
|
||||
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
|
||||
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
-(void)initData{
|
||||
self.titleArr=@[@"预警设置",@"背光亮度",@"柜灯开关",@"换水提醒",@"定时模式"];
|
||||
|
||||
ZeroControlBackmsgModel*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"DeviceBackZeroControlInfo"];
|
||||
if (backmodel) {
|
||||
NSString*low=backmodel.miniTp;
|
||||
NSString*heigh=backmodel.maxTp;
|
||||
UInt64 lowten=[dataContorl hexToTen:low];
|
||||
UInt64 heighten=[dataContorl hexToTen:heigh];
|
||||
float formatlow=lowten/10;
|
||||
float formatheigh=heighten/10;
|
||||
|
||||
NSString*wenduString=[NSString stringWithFormat:@"%.0f~%.0f°C",formatlow,formatheigh];
|
||||
|
||||
self.timeArr=@[wenduString];
|
||||
|
||||
}else{
|
||||
[self showTitle:@"" messsage:@"设备已离线"];
|
||||
self.timeArr=@[@"20~30°C"];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Table view data source
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
|
||||
return 5;
|
||||
}
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
ZeroControlBackmsgModel*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"DeviceBackZeroControlInfo"];
|
||||
|
||||
static NSString *cellID=@"kongCell";
|
||||
|
||||
UITableViewCell *kongCell=[tableView dequeueReusableCellWithIdentifier:cellID];
|
||||
|
||||
if (kongCell==nil) {
|
||||
|
||||
kongCell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (indexPath.row==0){
|
||||
|
||||
TemperatureSetCell*cell=[tableView dequeueReusableCellWithIdentifier:@"TemperatureSetCell"];
|
||||
if (cell==nil) {
|
||||
cell=[[[NSBundle mainBundle]loadNibNamed:@"TemperatureSetCell" owner:self options:nil]lastObject];
|
||||
}
|
||||
|
||||
TemperatureSetModel*model=[[TemperatureSetModel alloc]init];
|
||||
|
||||
model.title=self.titleArr[indexPath.row];
|
||||
|
||||
cell.titleLabel.text=model.title;
|
||||
model.temperatureLabel=self.timeArr[indexPath.row];
|
||||
cell.temperaturelabel.text=model.temperatureLabel;
|
||||
[cell.temPSwitch addTarget:self action:@selector(tempSwitchAction:) forControlEvents:UIControlEventValueChanged];
|
||||
if ([backmodel.baojingSwitch isEqualToString:@"01"]) {
|
||||
[cell.temPSwitch setBackgroundImage:[UIImage imageNamed:@"greenbtn_big"] forState:UIControlStateNormal];
|
||||
|
||||
cell.temPSwitch.selected = NO;
|
||||
|
||||
}else{
|
||||
[cell.temPSwitch setBackgroundImage:[UIImage imageNamed:@"graybtn_big"] forState:UIControlStateNormal];
|
||||
cell.temPSwitch.selected = YES;
|
||||
}
|
||||
|
||||
return cell;
|
||||
|
||||
}else if (indexPath.row==1){
|
||||
//背光
|
||||
|
||||
BrightnessCell*cell=[tableView dequeueReusableCellWithIdentifier:@"BrightnessCell"];
|
||||
if (cell==nil) {
|
||||
cell=[[[NSBundle mainBundle]loadNibNamed:@"BrightnessCell" owner:self options:nil]lastObject];
|
||||
}
|
||||
|
||||
if (![_currentdevice.isLightness isEqual:[NSNull null]]) {
|
||||
if ([_currentdevice.isLightness isEqualToString:@"1"]) {
|
||||
//有背光
|
||||
cell.brightTitleLabel.text=_titleArr[indexPath.row];
|
||||
// 系统默认YES 这里拖拽结束时再传值需设为NO
|
||||
cell.btightnessSlider.continuous=NO;
|
||||
if (backmodel) {
|
||||
|
||||
UInt64 lightTen=[dataContorl hexToTen:backmodel.brightness];
|
||||
|
||||
[cell.btightnessSlider setValue:lightTen animated:YES];
|
||||
// int sliderValue=(int)(lightTen+0.5);
|
||||
// int percent=(sliderValue*100)/250;
|
||||
// cell.persentLabel.text=[NSString stringWithFormat:@"%d%",percent];
|
||||
// cell.persentLabel.textColor=COLOR_LABEL_TITLE;
|
||||
}
|
||||
|
||||
[cell.btightnessSlider addTarget:self action:@selector(zerobtightnessSlider:) forControlEvents:UIControlEventValueChanged];
|
||||
|
||||
cell.brightTitleLabel.hidden=NO;
|
||||
cell.btightnessSlider.hidden=NO;
|
||||
cell.persentLabel.hidden=NO;
|
||||
|
||||
return cell;
|
||||
}else{
|
||||
//无背光
|
||||
|
||||
return kongCell;
|
||||
|
||||
}
|
||||
|
||||
}else{
|
||||
return kongCell;
|
||||
}
|
||||
|
||||
|
||||
}else if (indexPath.row==2){
|
||||
// 柜灯
|
||||
GuiDengViewCell*cell=[tableView dequeueReusableCellWithIdentifier:@"GuiDengViewCell"];
|
||||
if (cell==nil) {
|
||||
cell=[[[NSBundle mainBundle]loadNibNamed:@"GuiDengViewCell" owner:self options:nil]lastObject];
|
||||
}
|
||||
|
||||
if (![_currentdevice.isSarkLamp isEqual:[NSNull null]]) {
|
||||
if ([_currentdevice.isSarkLamp isEqualToString:@"1"]) {
|
||||
cell.guidengtitle=_titleArr[indexPath.row];
|
||||
|
||||
[cell.guidengSwitch addTarget:self action:@selector(zeroguidengSwitchAtion:) forControlEvents:UIControlEventTouchUpInside];
|
||||
if ([backmodel.tankLight isEqualToString:@"01"]) {
|
||||
|
||||
[cell.guidengSwitch setBackgroundImage:[UIImage imageNamed:@"greenbtn_big"] forState:UIControlStateNormal];
|
||||
cell.guidengSwitch.selected = NO;
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
[cell.guidengSwitch setBackgroundImage:[UIImage imageNamed:@"graybtn_big"] forState:UIControlStateNormal];
|
||||
cell.guidengSwitch.selected = YES;
|
||||
|
||||
}
|
||||
|
||||
return cell;
|
||||
|
||||
}else{
|
||||
|
||||
return kongCell;
|
||||
|
||||
}
|
||||
|
||||
}else{
|
||||
return kongCell;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}else if (indexPath.row==3){
|
||||
// 换水提醒
|
||||
|
||||
|
||||
ChangeWaterCell*cell=[tableView dequeueReusableCellWithIdentifier:@"ChangeWaterCell"];
|
||||
if (cell==nil) {
|
||||
cell=[[[NSBundle mainBundle]loadNibNamed:@"ChangeWaterCell" owner:self options:nil]lastObject];
|
||||
}
|
||||
|
||||
[cell.ChangeWaterSwitch addTarget:self action:@selector(zerochangeWaterSwitch:) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
|
||||
|
||||
|
||||
if (![self.currentdevice.waterRemind isEqual:[NSNull null]]) {
|
||||
|
||||
if ([self.waterInfmodel.waterremind isEqualToString:@"1"]) {
|
||||
//[cell.ChangeWaterSwitch setOn:YES];
|
||||
cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"firstSetCell"]];
|
||||
cell.ChangeWaterSwitch.selected = NO;
|
||||
[cell.ChangeWaterSwitch setBackgroundImage:[UIImage imageNamed:@"greenbtn_big"] forState:UIControlStateNormal];
|
||||
|
||||
_huanshuiSwitchIsOn=YES;
|
||||
}else{
|
||||
// [cell.ChangeWaterSwitch setOn:NO];
|
||||
_huanshuiSwitchIsOn=NO;
|
||||
|
||||
cell.ChangeWaterSwitch.selected = YES;
|
||||
[cell.ChangeWaterSwitch setBackgroundImage:[UIImage imageNamed:@"graybtn_big"] forState:UIControlStateNormal];
|
||||
cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"set_cellBack"]];
|
||||
|
||||
}
|
||||
|
||||
if (!self.waterInfmodel.remindcycle) {
|
||||
//在未获取换水信息时暂时显示
|
||||
cell.huanshuiDaylabel.text=@"换水时间";
|
||||
}else{
|
||||
cell.huanshuiDaylabel.text=[NSString stringWithFormat:@"%ld天",(long)self.waterInfmodel.remindcycle];
|
||||
}
|
||||
|
||||
NSLog(@"你");
|
||||
return cell;
|
||||
|
||||
}else{
|
||||
|
||||
kongCell.textLabel.text =@"错误信息 waterRemind null";
|
||||
return kongCell;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}else if(indexPath.row==4){
|
||||
|
||||
static NSString*nextHuanShuiLablecellId=@"labelcell";
|
||||
UITableViewCell*cell=[tableView dequeueReusableCellWithIdentifier:nextHuanShuiLablecellId];
|
||||
if (cell==nil) {
|
||||
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nextHuanShuiLablecellId];
|
||||
}
|
||||
if (_huanshuiSwitchIsOn) {
|
||||
cell.backgroundColor=COLOR_BACK_;
|
||||
cell.textLabel.text=[NSString stringWithFormat:@"下次换水时间:%@",self.waterInfmodel.remindDate];
|
||||
cell.textLabel.font=[UIFont systemFontOfSize:12];
|
||||
[cell.textLabel sizeToFit];
|
||||
cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"secondSetCell"]];
|
||||
}else{
|
||||
cell.textLabel.text=@"";
|
||||
}
|
||||
cell.userInteractionEnabled = NO;
|
||||
return cell;
|
||||
|
||||
|
||||
}
|
||||
return nil;
|
||||
|
||||
}
|
||||
#pragma mark 柜光灯开关Action
|
||||
|
||||
-(void)zeroguidengSwitchAtion:(UIButton*)sender{
|
||||
UIButton *switchButton = (UIButton*)sender;
|
||||
// BOOL isButtonOn=[switchButton isOn];
|
||||
GuidengKaiGuanModel*guidengModel=[[GuidengKaiGuanModel alloc]init];
|
||||
guidengModel.sendmacId = self.currentdevice.macAddress;
|
||||
guidengModel.resavemacId = self.currentdevice.macAddress;
|
||||
|
||||
guidengModel.crc16Str=@"0000";
|
||||
if (switchButton.selected == YES) {
|
||||
NSLog(@"开");
|
||||
guidengModel.onOff=@"01";
|
||||
switchButton.selected = NO;
|
||||
NSString* guidengOrder=[NSString stringWithFormat:@"%@%@%@",guidengModel.description,guidengModel.onOff,guidengModel.crc16Str];
|
||||
NSData*guidengData=[dataContorl stringToHexData:guidengOrder];
|
||||
[[Socketsingleton sharedInstance] soketWriteData:guidengData];
|
||||
TwoControlBackmsgmodel*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"DeviceBackTwoControlInfo"];
|
||||
backmodel.tankLight=@"01";
|
||||
[_indicatorView startAnimating];
|
||||
}else{
|
||||
NSLog(@"关");
|
||||
guidengModel.onOff=@"00";
|
||||
switchButton.selected = YES;
|
||||
NSString* guidengOrder=[NSString stringWithFormat:@"%@%@%@",guidengModel.description,guidengModel.onOff,guidengModel.crc16Str];
|
||||
NSData*guidengData=[dataContorl stringToHexData:guidengOrder];
|
||||
[[Socketsingleton sharedInstance] soketWriteData:guidengData];
|
||||
TwoControlBackmsgmodel*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"DeviceBackTwoControlInfo"];
|
||||
backmodel.tankLight=@"00";
|
||||
[_indicatorView startAnimating];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#pragma mark 背光灯亮度Action
|
||||
|
||||
-(void)zerobtightnessSlider:(UISlider*)sender{
|
||||
UISlider*slider=(UISlider*)sender;
|
||||
NSLog(@"%f",slider.value);
|
||||
//这里 只传整数
|
||||
//1.强转四舍五入
|
||||
|
||||
int sliderValue=(int)(slider.value+0.5);
|
||||
// //2.高斯函数,向下取整
|
||||
// int sliderValue1=floor(slider.value);
|
||||
// //3. ceil 函数,向上取整
|
||||
// int sliderValue2=ceil(slider.value);
|
||||
|
||||
NSLog(@"%d",sliderValue);
|
||||
|
||||
self.percent=(sliderValue*100)/250;
|
||||
|
||||
NSString*hexString=[dataContorl ToHex:sliderValue];
|
||||
|
||||
if (hexString.length<2) {
|
||||
|
||||
hexString=[NSString stringWithFormat:@"0%@",hexString];
|
||||
}
|
||||
NSLog(@"%@",hexString);
|
||||
|
||||
BrightnessModel*brightModel=[[BrightnessModel alloc]init
|
||||
];
|
||||
brightModel.sendmacId = self.currentdevice.macAddress;
|
||||
brightModel.resavemacId = self.currentdevice.macAddress;
|
||||
|
||||
brightModel.liangdu=hexString;
|
||||
brightModel.crc16Code=@"0000";
|
||||
NSString*changeLightOder=[NSString stringWithFormat:@"%@%@%@",brightModel.description,brightModel.liangdu,brightModel.crc16Code];
|
||||
NSData*changeLghtData=[dataContorl stringToHexData:changeLightOder];
|
||||
[[Socketsingleton sharedInstance] soketWriteData:changeLghtData];
|
||||
[_indicatorView startAnimating];
|
||||
|
||||
|
||||
}
|
||||
|
||||
#pragma mark 换水提醒Action
|
||||
-(void)zerochangeWaterSwitch:(UIButton*)sender{
|
||||
|
||||
UIButton*huanShuiSwitch=(UIButton*)sender;
|
||||
//BOOL isButtonOn=[huanShuiSwitch isOn];
|
||||
|
||||
NSUserDefaults*defuat=[NSUserDefaults standardUserDefaults];
|
||||
NSString*picResult=[defuat valueForKey:@"zeropicResult"];
|
||||
int pic = picResult.intValue;
|
||||
if (pic==0) {
|
||||
[self showTitle:@"" messsage:@"请设置提醒天数"];
|
||||
if (huanShuiSwitch.selected == YES) {
|
||||
huanShuiSwitch.selected = NO;
|
||||
}else{
|
||||
huanShuiSwitch.selected = YES;
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
|
||||
if (huanShuiSwitch.selected == YES) {
|
||||
//开
|
||||
huanShuiSwitch.selected = NO;
|
||||
[IFISHHTTPTOOL setRemindWaterInfWith:self.currentdevice.deviceId
|
||||
waterRemind:@"1" remindCycle:picResult
|
||||
huishuiShiJian:^(setRemindWaterModel *remindModel) {
|
||||
self.nextChangeDateLabel=remindModel.remindDate;
|
||||
|
||||
}];
|
||||
//更新选择状态 设置界面 在不断 刷新
|
||||
|
||||
self.waterInfmodel.waterremind=@"1";
|
||||
[self.tableView reloadData];
|
||||
|
||||
}else{
|
||||
//关
|
||||
huanShuiSwitch.selected = YES;
|
||||
[IFISHHTTPTOOL setRemindWaterInfWith:self.currentdevice.deviceId
|
||||
waterRemind:@"0" remindCycle:picResult
|
||||
huishuiShiJian:^(setRemindWaterModel *remindModel) {
|
||||
self.nextChangeDateLabel=remindModel.remindDate;
|
||||
|
||||
}];
|
||||
|
||||
self.waterInfmodel.waterremind=@"0";
|
||||
[self.tableView reloadData];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma mark 开启关闭报警
|
||||
-(void)tempSwitchAction:(UIButton*)temperatureSwitch{
|
||||
ZeroControlBackmsgModel*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"DeviceBackZeroControlInfo"];
|
||||
setWaringTpModel*warModel1=[[setWaringTpModel alloc]init];
|
||||
warModel1.resavemacId = self.currentdevice.macAddress;
|
||||
warModel1.sendmacId = self.currentdevice.macAddress;
|
||||
|
||||
//BOOL isOn=[temperatureSwitch isOn];
|
||||
if (temperatureSwitch.selected ==YES) {
|
||||
NSLog(@"开");
|
||||
temperatureSwitch.selected =NO;
|
||||
warModel1.kaiguan=@"01";// 开
|
||||
warModel1.miniwaterTp=@"0000"; // 0
|
||||
warModel1.maxwaterTp=@"0000";//0
|
||||
}else{
|
||||
temperatureSwitch.selected =YES;
|
||||
warModel1.kaiguan=@"00";// 关
|
||||
warModel1.miniwaterTp=@"0000"; // 0
|
||||
warModel1.maxwaterTp=@"0000";//0
|
||||
NSLog(@"关");
|
||||
}
|
||||
[self setTmperatureStateWithModel:warModel1 addBackModel:backmodel];
|
||||
|
||||
}
|
||||
-(void)setTmperatureStateWithModel:(setWaringTpModel*)waringModel addBackModel:(ZeroControlBackmsgModel*)backModel{
|
||||
NSString*maxminTpString=waringModel.description;
|
||||
waringModel.crc16Ing=@"0000";
|
||||
NSString*minString=[NSString stringWithFormat:@"%@%@%@%@%@",maxminTpString,waringModel.kaiguan,waringModel.miniwaterTp,waringModel.maxwaterTp,waringModel.crc16Ing];
|
||||
NSData*minwenDuData=[dataContorl stringToHexData:minString];
|
||||
[[Socketsingleton sharedInstance] soketWriteData:minwenDuData];
|
||||
[_indicatorView startAnimating];
|
||||
backModel.miniTp=waringModel.miniwaterTp;
|
||||
backModel.maxTp=waringModel.maxwaterTp;
|
||||
|
||||
}
|
||||
#pragma mark tableView 头视图和脚视图
|
||||
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
|
||||
if (indexPath.row==4) {
|
||||
|
||||
//ChangeWaterCell*cell=(ChangeWaterCell*)[self tableView:tableView cellForRowAtIndexPath:indexPath];
|
||||
|
||||
|
||||
if (_huanshuiSwitchIsOn) {
|
||||
|
||||
return 50;
|
||||
}else{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}else if (indexPath.row==1){
|
||||
|
||||
if (![_currentdevice.isLightness isEqual:[NSNull null]]) {
|
||||
|
||||
if ([_currentdevice.isLightness isEqualToString:@"1"]) {
|
||||
|
||||
return 100;
|
||||
}else{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}else if (indexPath.row==2){
|
||||
//
|
||||
|
||||
if (![_currentdevice.isSarkLamp isEqual:[NSNull null]]) {
|
||||
|
||||
if ([_currentdevice.isSarkLamp isEqualToString:@"1"]) {
|
||||
return 50;
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}else if (indexPath.row==5){
|
||||
//_currentdevice.isWorkModel=@"0";
|
||||
//运行模式
|
||||
if (![_currentdevice.isWorkModel isEqual:[NSNull null]]) {
|
||||
if ([_currentdevice.isWorkModel isEqualToString:@"1"]) {
|
||||
|
||||
return 50;
|
||||
|
||||
}else{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}else if (indexPath.row==3){
|
||||
|
||||
if (![_currentdevice.waterRemind isEqual:[NSNull null]]) {
|
||||
|
||||
|
||||
return 50;
|
||||
|
||||
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}else if (indexPath.row==0){
|
||||
//会否有 预警
|
||||
if (![_currentdevice.isPushWendu isEqual:[NSNull null]]) {
|
||||
|
||||
|
||||
if ([_currentdevice.isPushWendu isEqualToString:@"1"]) {
|
||||
return 50;
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
return 50;
|
||||
}
|
||||
|
||||
}
|
||||
#pragma mark tableView 点击事件
|
||||
|
||||
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
_indexpath=indexPath;
|
||||
if (indexPath.row==0&&indexPath.section==0) {
|
||||
|
||||
_mypicView=[[MyPickerView alloc]init];
|
||||
|
||||
_mypicView.frame=CGRectMake(0, 0, kScreenSize.width, kScreenSize.height);
|
||||
[self.view.window addSubview:_mypicView];
|
||||
[_mypicView.cancleButton addTarget:self action:@selector(mypicviewRemoveByCancle) forControlEvents:UIControlEventTouchUpInside];
|
||||
[_mypicView.sureButton addTarget:self action:@selector(mypicViewRemoveByDone) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self temperatureMainQueue];
|
||||
|
||||
}else if (indexPath.section==0&&indexPath.row==3){
|
||||
//换水提醒日期选择
|
||||
_remindPic=[[remindCyclePic alloc]init];
|
||||
|
||||
_remindPic.frame=CGRectMake(0, 0, kScreenSize.width, kScreenSize.height);
|
||||
[self.view.window addSubview:_remindPic];
|
||||
[_remindPic.cancleBtn addTarget:self action:@selector(zeroremindCyclePicRemove) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
[_remindPic.sureBtn addTarget:self action:@selector(zeroremindCyclePicDone) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self huanShuiMainQueue];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
#pragma mark 移除换水时间选择器
|
||||
|
||||
-(void)zeroremindCyclePicRemove{
|
||||
[_remindPic removeFromSuperview];
|
||||
// if (_indexpath.section==0&&_indexpath.row==3) {
|
||||
// ChangeWaterCell*cell=[self.tableView cellForRowAtIndexPath:_indexpath];
|
||||
// cell.huanshuiDaylabel.text=[NSString stringWithFormat:@"%@天",_currentdevice.remindCycle];
|
||||
// [self.tableView reloadData];
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
#pragma mark 换水时间设置
|
||||
|
||||
-(void)zeroremindCyclePicDone{
|
||||
|
||||
if (_indexpath.section==0&&_indexpath.row==3) {
|
||||
ChangeWaterCell*cell=[self.tableView cellForRowAtIndexPath:_indexpath];
|
||||
NSString *str=_remindPic.picViewResultString;
|
||||
if (str==nil) {
|
||||
//str=@"1";
|
||||
|
||||
NSLog(@"ni hua dong tai kuai");
|
||||
|
||||
str=[NSString stringWithFormat:@"%ld",(long)self.waterInfmodel.remindcycle];
|
||||
[_remindPic makeToast:@"请设置换水天数"];
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
cell.huanshuiDaylabel.text=[NSString stringWithFormat:@"%@天",str];
|
||||
//设置换水日期
|
||||
[IFISHHTTPTOOL setRemindWaterInfWith:self.currentdevice.deviceId
|
||||
waterRemind:@"1" remindCycle:str
|
||||
huishuiShiJian:^(setRemindWaterModel *remindModel) {
|
||||
|
||||
self.nextChangeDateLabel=remindModel.remindDate;
|
||||
self.waterInfmodel.waterremind=@"1";
|
||||
self.waterInfmodel.remindDate=remindModel.remindDate;
|
||||
self.waterInfmodel.remindcycle = remindModel.remindcycle;
|
||||
[self.tableView reloadData];
|
||||
|
||||
}];
|
||||
|
||||
NSUserDefaults*defuat=[NSUserDefaults standardUserDefaults];
|
||||
|
||||
[defuat setValue:str forKey:@"picResult"];
|
||||
|
||||
[defuat synchronize];
|
||||
|
||||
[_remindPic removeFromSuperview];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark 默认换水时间
|
||||
-(void)huanShuiMainQueue{
|
||||
if (_remindPic.picViewResultString !=nil || (_remindPic.picViewResultString ==nil && self.waterInfmodel.remindcycle !=0 )) {
|
||||
|
||||
|
||||
NSArray*shijianArr=[_remindPic.picArr objectAtIndex:0];
|
||||
dispatch_async(_mainQueue, ^{
|
||||
NSLog(@"a");
|
||||
for (NSInteger k=0; k<shijianArr.count; k++) {
|
||||
ChangeWaterCell*cell=(ChangeWaterCell*)[self tableView:self.tableView cellForRowAtIndexPath:_indexpath];
|
||||
|
||||
NSString*dateString=cell.huanshuiDaylabel.text;
|
||||
|
||||
NSString*start=nil;
|
||||
if (self.waterInfmodel.remindcycle == 0) {
|
||||
//未设置换水时间时 默认为1
|
||||
start = @"1";
|
||||
}else{
|
||||
|
||||
NSRange range=[dateString rangeOfString:@"天"];
|
||||
start=[dateString substringToIndex:range.location];
|
||||
}
|
||||
|
||||
//判断数据源数组小于十的情况
|
||||
//_remindPic.picViewResultString=dateString;
|
||||
NSString*picString=shijianArr[k];
|
||||
|
||||
if ([picString isEqualToString:start] ) {
|
||||
|
||||
[_remindPic.pic selectRow:k inComponent:0 animated:NO];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-(void)temperatureMainQueue{
|
||||
NSArray*lowArr=[_mypicView.picArr objectAtIndex:0];
|
||||
NSArray*heighArr=[_mypicView.picArr objectAtIndex:2];
|
||||
|
||||
dispatch_async(_mainQueue, ^{
|
||||
for (NSInteger i=0; i<lowArr.count; i++) {
|
||||
NSString*tempretureString=_timeArr[_indexpath.row];
|
||||
NSString*tempretureString1=[tempretureString substringWithRange:NSMakeRange(0, tempretureString.length-2)];
|
||||
|
||||
NSRange range=[tempretureString1 rangeOfString:@"~"];
|
||||
NSString*start=[tempretureString1 substringToIndex:range.location];
|
||||
|
||||
|
||||
NSString*startpicString=lowArr[i];
|
||||
|
||||
if ([startpicString isEqualToString:start ] ) {
|
||||
|
||||
[_mypicView.picView selectRow:i inComponent:0 animated:NO];
|
||||
_mypicView.lowindex=i;
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
dispatch_async(_mainQueue, ^{
|
||||
for (NSInteger j=0; j<heighArr.count; j++) {
|
||||
NSString*tempretureString=_timeArr[_indexpath.row];
|
||||
NSString*tempretureString1=[tempretureString substringWithRange:NSMakeRange(0, tempretureString.length-2)];
|
||||
|
||||
NSRange range=[tempretureString1 rangeOfString:@"~"];
|
||||
NSString*start=[tempretureString1 substringFromIndex:range.location+1];
|
||||
|
||||
NSString*startpicString=heighArr[j];
|
||||
|
||||
if ([startpicString isEqualToString:start ] ) {
|
||||
|
||||
[_mypicView.picView selectRow:j inComponent:2 animated:NO];
|
||||
_mypicView.heighindex=j;
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
-(void)mypicviewRemoveByCancle{
|
||||
[_mypicView removeFromSuperview];
|
||||
|
||||
}
|
||||
|
||||
//温度设置
|
||||
#pragma mark 温度设置
|
||||
-(void)mypicViewRemoveByDone{
|
||||
|
||||
if (_mypicView.picViewResultString==nil) {
|
||||
[_mypicView removeFromSuperview];
|
||||
|
||||
}else{
|
||||
if (_indexpath.row==0) {
|
||||
|
||||
TemperatureSetCell*cell=[self.tableView cellForRowAtIndexPath:_indexpath];
|
||||
cell.temperaturelabel.text=[NSString stringWithFormat:@"%@°C",_mypicView.picViewResultString];
|
||||
}
|
||||
ZeroControlBackmsgModel*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"DeviceBackZeroControlInfo"];
|
||||
// 低温
|
||||
setWaringTpModel*warModel1=[[setWaringTpModel alloc]init];
|
||||
warModel1.resavemacId = self.currentdevice.macAddress;
|
||||
warModel1.sendmacId = self.currentdevice.macAddress;
|
||||
|
||||
warModel1.crc16Ing=@"0000";
|
||||
warModel1.kaiguan=@"02";//设置
|
||||
NSString*maxminTpString=warModel1.description;
|
||||
|
||||
NSRange range=[_mypicView.picViewResultString rangeOfString:@"~"];
|
||||
NSString*lowString=[_mypicView.picViewResultString substringToIndex:range.location];
|
||||
|
||||
int intlowString = [lowString intValue];
|
||||
int newIntlowString=intlowString*10;
|
||||
warModel1.miniwaterTp=[dataContorl tpIntStringToFourHex:newIntlowString]; // 转四位16进制
|
||||
//写入数据
|
||||
backmodel.miniTp=warModel1.miniwaterTp;
|
||||
|
||||
// 高温
|
||||
setWaringTpModel*warModel2=[[setWaringTpModel alloc]init];
|
||||
warModel2.resavemacId = self.currentdevice.macAddress;
|
||||
warModel2.sendmacId = self.currentdevice.macAddress;
|
||||
|
||||
warModel2.crc16Ing=@"0000";
|
||||
warModel2.kaiguan=@"02";//设置
|
||||
NSString*heighString=[_mypicView.picViewResultString substringFromIndex:range.location+1];
|
||||
int intString = [heighString intValue];
|
||||
int newIntString=intString*10;
|
||||
|
||||
warModel2.maxwaterTp=[dataContorl tpIntStringToFourHex:newIntString];
|
||||
|
||||
if ([lowString intValue]<[heighString intValue]) {
|
||||
|
||||
backmodel.miniTp=warModel1.miniwaterTp;
|
||||
NSString*minString=[NSString stringWithFormat:@"%@%@%@%@%@",maxminTpString,warModel1.kaiguan,warModel1.miniwaterTp,warModel2.maxwaterTp,warModel1.crc16Ing];
|
||||
NSData*minwenDuData=[dataContorl stringToHexData:minString];
|
||||
[[Socketsingleton sharedInstance] soketWriteData:minwenDuData];
|
||||
backmodel.maxTp=warModel2.maxwaterTp;
|
||||
|
||||
[_indicatorView startAnimating];
|
||||
[_mypicView removeFromSuperview];
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
[self showTitle:@"提醒" messsage:@"请正确设置温度"];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#pragma mark 导航条 跳转时处理
|
||||
-(void)viewWillAppear:(BOOL)animated{
|
||||
self.navigationController.navigationBarHidden=NO;
|
||||
if (_currentdevice) {
|
||||
[IFISHHTTPTOOL getRemindWaterInfWith:_currentdevice.deviceId huishuiInfo:^(setRemindWaterModel *remindModel) {
|
||||
|
||||
self.waterInfmodel=remindModel;
|
||||
|
||||
NSUserDefaults*defuat=[NSUserDefaults standardUserDefaults];
|
||||
//[defuat setValue: self.waterInfmodel.remindcycle forKey:@"zeropicResult"];
|
||||
[defuat setInteger: self.waterInfmodel.remindcycle forKey:@"zeropicResult"];
|
||||
[defuat synchronize];
|
||||
|
||||
[self.tableView reloadData];
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(void)viewWillDisappear:(BOOL)animated{
|
||||
|
||||
[_indicatorView stopAnimating];
|
||||
}
|
||||
#pragma mark alert 动态显示
|
||||
-(void)showAlert{
|
||||
NSString*title=nil;
|
||||
NSString*message=@"已经与服务器断开连接";
|
||||
NSTimeInterval dismissSeconds=2.0;
|
||||
UIAlertView*alertView=[[UIAlertView alloc]initWithTitle:title message:message delegate:nil cancelButtonTitle:nil otherButtonTitles:nil, nil];
|
||||
[alertView show];
|
||||
[self performSelector:@selector(dismissAlert:) withObject:alertView afterDelay:dismissSeconds];
|
||||
}
|
||||
-(void)dismissAlert:(UIAlertView*)alertView{
|
||||
|
||||
[alertView dismissWithClickedButtonIndex:[alertView cancelButtonIndex] animated:YES];
|
||||
}
|
||||
//
|
||||
-(void)addAlertView{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self showAlert];
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
-(void)showTitle:(NSString*)title messsage:(NSString*)message{
|
||||
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:title message:message delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
|
||||
[alert show];
|
||||
}
|
||||
-(void)creatIndicatorView{
|
||||
|
||||
_indicatorView=[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
|
||||
_indicatorView.frame=CGRectMake(kScreenSize.width/2-50,kScreenSize.height/2-100,100, 100);
|
||||
_indicatorView.backgroundColor=[UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
|
||||
_indicatorView.layer.masksToBounds=YES;
|
||||
_indicatorView.layer.cornerRadius=5;
|
||||
AppDelegate*delegate=[[UIApplication sharedApplication]delegate];
|
||||
[delegate.window addSubview:_indicatorView];
|
||||
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user