Commit 37b07214 authored by lujunye's avatar lujunye

安静了;阿酸豆角啊打发时间;拉水电费;浪费

parent e1d93a92
...@@ -318,9 +318,6 @@ ...@@ -318,9 +318,6 @@
E0AA7F352589A8AA0099193F /* jcore-ios-2.4.0.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E0AA7F302589A8AA0099193F /* jcore-ios-2.4.0.a */; }; E0AA7F352589A8AA0099193F /* jcore-ios-2.4.0.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E0AA7F302589A8AA0099193F /* jcore-ios-2.4.0.a */; };
E0AA7F362589A8AA0099193F /* jpush-ios-3.4.0.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E0AA7F332589A8AA0099193F /* jpush-ios-3.4.0.a */; }; E0AA7F362589A8AA0099193F /* jpush-ios-3.4.0.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E0AA7F332589A8AA0099193F /* jpush-ios-3.4.0.a */; };
E0AACC76255BB03C00FC9010 /* TitleAndSelectCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0AACC75255BB03C00FC9010 /* TitleAndSelectCell.swift */; }; E0AACC76255BB03C00FC9010 /* TitleAndSelectCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0AACC75255BB03C00FC9010 /* TitleAndSelectCell.swift */; };
E0AC418025E88B0700805AE3 /* ConnectViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E0AC417E25E88B0700805AE3 /* ConnectViewController.m */; };
E0AC418125E88B0700805AE3 /* ConnectViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E0AC417F25E88B0700805AE3 /* ConnectViewController.xib */; };
E0AC419E25E894E400805AE3 /* libGSDK.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E0AC419C25E894E400805AE3 /* libGSDK.a */; };
E0AD92E92550E50500D82C17 /* GYS_FX_Product_VC.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0AD92E72550E50500D82C17 /* GYS_FX_Product_VC.swift */; }; E0AD92E92550E50500D82C17 /* GYS_FX_Product_VC.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0AD92E72550E50500D82C17 /* GYS_FX_Product_VC.swift */; };
E0AD92EA2550E50500D82C17 /* GYS_FX_Product_VC.xib in Resources */ = {isa = PBXBuildFile; fileRef = E0AD92E82550E50500D82C17 /* GYS_FX_Product_VC.xib */; }; E0AD92EA2550E50500D82C17 /* GYS_FX_Product_VC.xib in Resources */ = {isa = PBXBuildFile; fileRef = E0AD92E82550E50500D82C17 /* GYS_FX_Product_VC.xib */; };
E0AD92F92550FD1500D82C17 /* GYS_FX_SearchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0AD92F72550FD1500D82C17 /* GYS_FX_SearchViewController.swift */; }; E0AD92F92550FD1500D82C17 /* GYS_FX_SearchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0AD92F72550FD1500D82C17 /* GYS_FX_SearchViewController.swift */; };
...@@ -404,6 +401,17 @@ ...@@ -404,6 +401,17 @@
E0D4166424483058008DCAB4 /* ChangePassViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0D4166224483058008DCAB4 /* ChangePassViewController.swift */; }; E0D4166424483058008DCAB4 /* ChangePassViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0D4166224483058008DCAB4 /* ChangePassViewController.swift */; };
E0D4166524483058008DCAB4 /* ChangePassViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E0D4166324483058008DCAB4 /* ChangePassViewController.xib */; }; E0D4166524483058008DCAB4 /* ChangePassViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E0D4166324483058008DCAB4 /* ChangePassViewController.xib */; };
E0D46C5724503EC50087B564 /* TitleAndSelectCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = E0D46C5524503EC50087B564 /* TitleAndSelectCell.xib */; }; E0D46C5724503EC50087B564 /* TitleAndSelectCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = E0D46C5524503EC50087B564 /* TitleAndSelectCell.xib */; };
E0DA8AAA25E8F3D800425099 /* HLBLEManager.m in Sources */ = {isa = PBXBuildFile; fileRef = E0DA8A9625E8F3D800425099 /* HLBLEManager.m */; };
E0DA8AAB25E8F3D800425099 /* SVRadialGradientLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = E0DA8A9925E8F3D800425099 /* SVRadialGradientLayer.m */; };
E0DA8AAC25E8F3D800425099 /* SVProgressAnimatedView.m in Sources */ = {isa = PBXBuildFile; fileRef = E0DA8A9C25E8F3D800425099 /* SVProgressAnimatedView.m */; };
E0DA8AAD25E8F3D800425099 /* SVProgressHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = E0DA8A9F25E8F3D800425099 /* SVProgressHUD.m */; };
E0DA8AAE25E8F3D800425099 /* SVIndefiniteAnimatedView.m in Sources */ = {isa = PBXBuildFile; fileRef = E0DA8AA025E8F3D800425099 /* SVIndefiniteAnimatedView.m */; };
E0DA8AAF25E8F3D800425099 /* SVProgressHUD.bundle in Resources */ = {isa = PBXBuildFile; fileRef = E0DA8AA125E8F3D800425099 /* SVProgressHUD.bundle */; };
E0DA8AB025E8F3D800425099 /* HLPrinter.m in Sources */ = {isa = PBXBuildFile; fileRef = E0DA8AA425E8F3D800425099 /* HLPrinter.m */; };
E0DA8AB125E8F3D800425099 /* UIWebView+UIImage.m in Sources */ = {isa = PBXBuildFile; fileRef = E0DA8AA525E8F3D800425099 /* UIWebView+UIImage.m */; };
E0DA8AB225E8F3D800425099 /* UIImage+Bitmap.m in Sources */ = {isa = PBXBuildFile; fileRef = E0DA8AA825E8F3D800425099 /* UIImage+Bitmap.m */; };
E0DA8ACF25E8F4C000425099 /* BtViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E0DA8ACD25E8F4C000425099 /* BtViewController.m */; };
E0DA8AD025E8F4C000425099 /* BtViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E0DA8ACE25E8F4C000425099 /* BtViewController.xib */; };
E0DDCB0F244AD8C500DF54C7 /* DaiQueRenCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0DDCB0D244AD8C500DF54C7 /* DaiQueRenCell.swift */; }; E0DDCB0F244AD8C500DF54C7 /* DaiQueRenCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0DDCB0D244AD8C500DF54C7 /* DaiQueRenCell.swift */; };
E0DDCB10244AD8C500DF54C7 /* DaiQueRenCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = E0DDCB0E244AD8C500DF54C7 /* DaiQueRenCell.xib */; }; E0DDCB10244AD8C500DF54C7 /* DaiQueRenCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = E0DDCB0E244AD8C500DF54C7 /* DaiQueRenCell.xib */; };
E0DDCB13244ADF2C00DF54C7 /* ChangePriceNormalCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0DDCB11244ADF2C00DF54C7 /* ChangePriceNormalCell.swift */; }; E0DDCB13244ADF2C00DF54C7 /* ChangePriceNormalCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0DDCB11244ADF2C00DF54C7 /* ChangePriceNormalCell.swift */; };
...@@ -423,6 +431,7 @@ ...@@ -423,6 +431,7 @@
E0E7CB6124C17B9F00A26D3F /* GLKHCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0E7CB5F24C17B9F00A26D3F /* GLKHCell.swift */; }; E0E7CB6124C17B9F00A26D3F /* GLKHCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0E7CB5F24C17B9F00A26D3F /* GLKHCell.swift */; };
E0E7CB6224C17B9F00A26D3F /* GLKHCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = E0E7CB6024C17B9F00A26D3F /* GLKHCell.xib */; }; E0E7CB6224C17B9F00A26D3F /* GLKHCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = E0E7CB6024C17B9F00A26D3F /* GLKHCell.xib */; };
E0E8ABFD246E359700E3BB54 /* GuiGeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0E8ABFC246E359700E3BB54 /* GuiGeModel.swift */; }; E0E8ABFD246E359700E3BB54 /* GuiGeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0E8ABFC246E359700E3BB54 /* GuiGeModel.swift */; };
E0E9D73025E8B2A200BC08EB /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E0E9D72F25E8B2A200BC08EB /* CoreBluetooth.framework */; };
E0E9FC3724CEC11000111738 /* HLLTopCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = E0E9FC3524CEC11000111738 /* HLLTopCell.xib */; }; E0E9FC3724CEC11000111738 /* HLLTopCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = E0E9FC3524CEC11000111738 /* HLLTopCell.xib */; };
E0E9FC3824CEC11000111738 /* HLLTopCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0E9FC3624CEC11000111738 /* HLLTopCell.swift */; }; E0E9FC3824CEC11000111738 /* HLLTopCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0E9FC3624CEC11000111738 /* HLLTopCell.swift */; };
E0EABAE72487748500F6CA8D /* NewSelectWarehouseVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0EABAE52487748500F6CA8D /* NewSelectWarehouseVC.swift */; }; E0EABAE72487748500F6CA8D /* NewSelectWarehouseVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0EABAE52487748500F6CA8D /* NewSelectWarehouseVC.swift */; };
...@@ -1048,17 +1057,6 @@ ...@@ -1048,17 +1057,6 @@
E0AA7F322589A8AA0099193F /* JPUSHService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JPUSHService.h; sourceTree = "<group>"; }; E0AA7F322589A8AA0099193F /* JPUSHService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JPUSHService.h; sourceTree = "<group>"; };
E0AA7F332589A8AA0099193F /* jpush-ios-3.4.0.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = "jpush-ios-3.4.0.a"; sourceTree = "<group>"; }; E0AA7F332589A8AA0099193F /* jpush-ios-3.4.0.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = "jpush-ios-3.4.0.a"; sourceTree = "<group>"; };
E0AACC75255BB03C00FC9010 /* TitleAndSelectCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TitleAndSelectCell.swift; sourceTree = "<group>"; }; E0AACC75255BB03C00FC9010 /* TitleAndSelectCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TitleAndSelectCell.swift; sourceTree = "<group>"; };
E0AC417D25E88B0700805AE3 /* ConnectViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConnectViewController.h; sourceTree = "<group>"; };
E0AC417E25E88B0700805AE3 /* ConnectViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ConnectViewController.m; sourceTree = "<group>"; };
E0AC417F25E88B0700805AE3 /* ConnectViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ConnectViewController.xib; sourceTree = "<group>"; };
E0AC419C25E894E400805AE3 /* libGSDK.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libGSDK.a; sourceTree = "<group>"; };
E0AC41A325E8952100805AE3 /* ReliableBurstData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReliableBurstData.h; sourceTree = "<group>"; };
E0AC41A425E8952100805AE3 /* DeviceInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceInfo.h; sourceTree = "<group>"; };
E0AC41A525E8952100805AE3 /* EscCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EscCommand.h; sourceTree = "<group>"; };
E0AC41A625E8952100805AE3 /* CBController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CBController.h; sourceTree = "<group>"; };
E0AC41A725E8952100805AE3 /* MyPeripheral.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MyPeripheral.h; sourceTree = "<group>"; };
E0AC41A825E8952100805AE3 /* TscCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TscCommand.h; sourceTree = "<group>"; };
E0AC41A925E8952100805AE3 /* BLKWrite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BLKWrite.h; sourceTree = "<group>"; };
E0AD92E72550E50500D82C17 /* GYS_FX_Product_VC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GYS_FX_Product_VC.swift; sourceTree = "<group>"; }; E0AD92E72550E50500D82C17 /* GYS_FX_Product_VC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GYS_FX_Product_VC.swift; sourceTree = "<group>"; };
E0AD92E82550E50500D82C17 /* GYS_FX_Product_VC.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = GYS_FX_Product_VC.xib; sourceTree = "<group>"; }; E0AD92E82550E50500D82C17 /* GYS_FX_Product_VC.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = GYS_FX_Product_VC.xib; sourceTree = "<group>"; };
E0AD92F72550FD1500D82C17 /* GYS_FX_SearchViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GYS_FX_SearchViewController.swift; sourceTree = "<group>"; }; E0AD92F72550FD1500D82C17 /* GYS_FX_SearchViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GYS_FX_SearchViewController.swift; sourceTree = "<group>"; };
...@@ -1151,6 +1149,28 @@ ...@@ -1151,6 +1149,28 @@
E0D4166224483058008DCAB4 /* ChangePassViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChangePassViewController.swift; sourceTree = "<group>"; }; E0D4166224483058008DCAB4 /* ChangePassViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChangePassViewController.swift; sourceTree = "<group>"; };
E0D4166324483058008DCAB4 /* ChangePassViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ChangePassViewController.xib; sourceTree = "<group>"; }; E0D4166324483058008DCAB4 /* ChangePassViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ChangePassViewController.xib; sourceTree = "<group>"; };
E0D46C5524503EC50087B564 /* TitleAndSelectCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = TitleAndSelectCell.xib; sourceTree = "<group>"; }; E0D46C5524503EC50087B564 /* TitleAndSelectCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = TitleAndSelectCell.xib; sourceTree = "<group>"; };
E0DA8A9525E8F3D800425099 /* HLBLEConst.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HLBLEConst.h; sourceTree = "<group>"; };
E0DA8A9625E8F3D800425099 /* HLBLEManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HLBLEManager.m; sourceTree = "<group>"; };
E0DA8A9725E8F3D800425099 /* HLBLEManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HLBLEManager.h; sourceTree = "<group>"; };
E0DA8A9925E8F3D800425099 /* SVRadialGradientLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVRadialGradientLayer.m; sourceTree = "<group>"; };
E0DA8A9A25E8F3D800425099 /* SVIndefiniteAnimatedView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVIndefiniteAnimatedView.h; sourceTree = "<group>"; };
E0DA8A9B25E8F3D800425099 /* SVProgressHUD.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVProgressHUD.h; sourceTree = "<group>"; };
E0DA8A9C25E8F3D800425099 /* SVProgressAnimatedView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVProgressAnimatedView.m; sourceTree = "<group>"; };
E0DA8A9D25E8F3D800425099 /* SVProgressHUD-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "SVProgressHUD-Prefix.pch"; sourceTree = "<group>"; };
E0DA8A9E25E8F3D800425099 /* SVRadialGradientLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVRadialGradientLayer.h; sourceTree = "<group>"; };
E0DA8A9F25E8F3D800425099 /* SVProgressHUD.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVProgressHUD.m; sourceTree = "<group>"; };
E0DA8AA025E8F3D800425099 /* SVIndefiniteAnimatedView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVIndefiniteAnimatedView.m; sourceTree = "<group>"; };
E0DA8AA125E8F3D800425099 /* SVProgressHUD.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = SVProgressHUD.bundle; sourceTree = "<group>"; };
E0DA8AA225E8F3D800425099 /* SVProgressAnimatedView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVProgressAnimatedView.h; sourceTree = "<group>"; };
E0DA8AA425E8F3D800425099 /* HLPrinter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HLPrinter.m; sourceTree = "<group>"; };
E0DA8AA525E8F3D800425099 /* UIWebView+UIImage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIWebView+UIImage.m"; sourceTree = "<group>"; };
E0DA8AA625E8F3D800425099 /* UIImage+Bitmap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+Bitmap.h"; sourceTree = "<group>"; };
E0DA8AA725E8F3D800425099 /* UIWebView+UIImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIWebView+UIImage.h"; sourceTree = "<group>"; };
E0DA8AA825E8F3D800425099 /* UIImage+Bitmap.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+Bitmap.m"; sourceTree = "<group>"; };
E0DA8AA925E8F3D800425099 /* HLPrinter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HLPrinter.h; sourceTree = "<group>"; };
E0DA8ACC25E8F4C000425099 /* BtViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BtViewController.h; sourceTree = "<group>"; };
E0DA8ACD25E8F4C000425099 /* BtViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BtViewController.m; sourceTree = "<group>"; };
E0DA8ACE25E8F4C000425099 /* BtViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = BtViewController.xib; sourceTree = "<group>"; };
E0DDCB0D244AD8C500DF54C7 /* DaiQueRenCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DaiQueRenCell.swift; sourceTree = "<group>"; }; E0DDCB0D244AD8C500DF54C7 /* DaiQueRenCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DaiQueRenCell.swift; sourceTree = "<group>"; };
E0DDCB0E244AD8C500DF54C7 /* DaiQueRenCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DaiQueRenCell.xib; sourceTree = "<group>"; }; E0DDCB0E244AD8C500DF54C7 /* DaiQueRenCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DaiQueRenCell.xib; sourceTree = "<group>"; };
E0DDCB11244ADF2C00DF54C7 /* ChangePriceNormalCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChangePriceNormalCell.swift; sourceTree = "<group>"; }; E0DDCB11244ADF2C00DF54C7 /* ChangePriceNormalCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChangePriceNormalCell.swift; sourceTree = "<group>"; };
...@@ -1170,6 +1190,7 @@ ...@@ -1170,6 +1190,7 @@
E0E7CB5F24C17B9F00A26D3F /* GLKHCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GLKHCell.swift; sourceTree = "<group>"; }; E0E7CB5F24C17B9F00A26D3F /* GLKHCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GLKHCell.swift; sourceTree = "<group>"; };
E0E7CB6024C17B9F00A26D3F /* GLKHCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = GLKHCell.xib; sourceTree = "<group>"; }; E0E7CB6024C17B9F00A26D3F /* GLKHCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = GLKHCell.xib; sourceTree = "<group>"; };
E0E8ABFC246E359700E3BB54 /* GuiGeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GuiGeModel.swift; sourceTree = "<group>"; }; E0E8ABFC246E359700E3BB54 /* GuiGeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GuiGeModel.swift; sourceTree = "<group>"; };
E0E9D72F25E8B2A200BC08EB /* CoreBluetooth.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreBluetooth.framework; path = System/Library/Frameworks/CoreBluetooth.framework; sourceTree = SDKROOT; };
E0E9FC3524CEC11000111738 /* HLLTopCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = HLLTopCell.xib; sourceTree = "<group>"; }; E0E9FC3524CEC11000111738 /* HLLTopCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = HLLTopCell.xib; sourceTree = "<group>"; };
E0E9FC3624CEC11000111738 /* HLLTopCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HLLTopCell.swift; sourceTree = "<group>"; }; E0E9FC3624CEC11000111738 /* HLLTopCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HLLTopCell.swift; sourceTree = "<group>"; };
E0EABAE52487748500F6CA8D /* NewSelectWarehouseVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewSelectWarehouseVC.swift; sourceTree = "<group>"; }; E0EABAE52487748500F6CA8D /* NewSelectWarehouseVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewSelectWarehouseVC.swift; sourceTree = "<group>"; };
...@@ -1506,7 +1527,6 @@ ...@@ -1506,7 +1527,6 @@
E09B3AE324B3011B00E3B238 /* libz.1.2.5.tbd in Frameworks */, E09B3AE324B3011B00E3B238 /* libz.1.2.5.tbd in Frameworks */,
E0707DC72462457200E039A8 /* libz.tbd in Frameworks */, E0707DC72462457200E039A8 /* libz.tbd in Frameworks */,
E09B3AE024B2FE0200E3B238 /* libicucore.tbd in Frameworks */, E09B3AE024B2FE0200E3B238 /* libicucore.tbd in Frameworks */,
E0AC419E25E894E400805AE3 /* libGSDK.a in Frameworks */,
E039848C2468F27800DFA56F /* libsqlite3.tbd in Frameworks */, E039848C2468F27800DFA56F /* libsqlite3.tbd in Frameworks */,
E09B3ADE24B2FDC600E3B238 /* JavaScriptCore.framework in Frameworks */, E09B3ADE24B2FDC600E3B238 /* JavaScriptCore.framework in Frameworks */,
E0AA7F362589A8AA0099193F /* jpush-ios-3.4.0.a in Frameworks */, E0AA7F362589A8AA0099193F /* jpush-ios-3.4.0.a in Frameworks */,
...@@ -1537,6 +1557,7 @@ ...@@ -1537,6 +1557,7 @@
E039847C2468F21900DFA56F /* AVFoundation.framework in Frameworks */, E039847C2468F21900DFA56F /* AVFoundation.framework in Frameworks */,
E039847A2468F21100DFA56F /* AudioToolbox.framework in Frameworks */, E039847A2468F21100DFA56F /* AudioToolbox.framework in Frameworks */,
E03984782468F20800DFA56F /* AssetsLibrary.framework in Frameworks */, E03984782468F20800DFA56F /* AssetsLibrary.framework in Frameworks */,
E0E9D73025E8B2A200BC08EB /* CoreBluetooth.framework in Frameworks */,
E0AA7F352589A8AA0099193F /* jcore-ios-2.4.0.a in Frameworks */, E0AA7F352589A8AA0099193F /* jcore-ios-2.4.0.a in Frameworks */,
F905A7D5246CF57700E3A74D /* Parchment in Frameworks */, F905A7D5246CF57700E3A74D /* Parchment in Frameworks */,
E0707DC52462456C00E039A8 /* libc++.tbd in Frameworks */, E0707DC52462456C00E039A8 /* libc++.tbd in Frameworks */,
...@@ -1569,6 +1590,7 @@ ...@@ -1569,6 +1590,7 @@
824621C23DA37CD28A2F345F /* Frameworks */ = { 824621C23DA37CD28A2F345F /* Frameworks */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
E0E9D72F25E8B2A200BC08EB /* CoreBluetooth.framework */,
E07C20CB24B301CD006CAB9D /* AuthenticationServices.framework */, E07C20CB24B301CD006CAB9D /* AuthenticationServices.framework */,
E09B3AE224B3011B00E3B238 /* libz.1.2.5.tbd */, E09B3AE224B3011B00E3B238 /* libz.1.2.5.tbd */,
E09B3ADF24B2FE0200E3B238 /* libicucore.tbd */, E09B3ADF24B2FE0200E3B238 /* libicucore.tbd */,
...@@ -2332,8 +2354,7 @@ ...@@ -2332,8 +2354,7 @@
E09B3AB624B2FCAF00E3B238 /* SDK */ = { E09B3AB624B2FCAF00E3B238 /* SDK */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
E0AC41A225E8952100805AE3 /* include */, E0DA8A9325E8F3C900425099 /* HLPrinter */,
E0AC419C25E894E400805AE3 /* libGSDK.a */,
E09B3AB724B2FCAF00E3B238 /* ShareSDK */, E09B3AB724B2FCAF00E3B238 /* ShareSDK */,
E09B3ACD24B2FCAF00E3B238 /* Required */, E09B3ACD24B2FCAF00E3B238 /* Required */,
); );
...@@ -2548,21 +2569,6 @@ ...@@ -2548,21 +2569,6 @@
path = Lib; path = Lib;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
E0AC41A225E8952100805AE3 /* include */ = {
isa = PBXGroup;
children = (
E0AC41A325E8952100805AE3 /* ReliableBurstData.h */,
E0AC41A425E8952100805AE3 /* DeviceInfo.h */,
E0AC41A525E8952100805AE3 /* EscCommand.h */,
E0AC41A625E8952100805AE3 /* CBController.h */,
E0AC41A725E8952100805AE3 /* MyPeripheral.h */,
E0AC41A825E8952100805AE3 /* TscCommand.h */,
E0AC41A925E8952100805AE3 /* BLKWrite.h */,
);
name = include;
path = ../../../../Downloads/GprinterSDKandDemoforIOS_v1.0.8/GprinterSDKforIOS_v1.0.8/include;
sourceTree = "<group>";
};
E0AD92E62550E4DD00D82C17 /* 供应商分销商品管理 */ = { E0AD92E62550E4DD00D82C17 /* 供应商分销商品管理 */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -2694,12 +2700,12 @@ ...@@ -2694,12 +2700,12 @@
E0D197CC244855F5002B080C /* 蓝牙连接 */ = { E0D197CC244855F5002B080C /* 蓝牙连接 */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
E0AC417D25E88B0700805AE3 /* ConnectViewController.h */,
E0AC417E25E88B0700805AE3 /* ConnectViewController.m */,
E0AC417F25E88B0700805AE3 /* ConnectViewController.xib */,
E01FD9C925E7A46C00964A20 /* Bt_Cell.h */, E01FD9C925E7A46C00964A20 /* Bt_Cell.h */,
E01FD9CA25E7A46C00964A20 /* Bt_Cell.m */, E01FD9CA25E7A46C00964A20 /* Bt_Cell.m */,
E01FD9CB25E7A46C00964A20 /* Bt_Cell.xib */, E01FD9CB25E7A46C00964A20 /* Bt_Cell.xib */,
E0DA8ACC25E8F4C000425099 /* BtViewController.h */,
E0DA8ACD25E8F4C000425099 /* BtViewController.m */,
E0DA8ACE25E8F4C000425099 /* BtViewController.xib */,
); );
path = "蓝牙连接"; path = "蓝牙连接";
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -2722,6 +2728,56 @@ ...@@ -2722,6 +2728,56 @@
path = "修改密码"; path = "修改密码";
sourceTree = "<group>"; sourceTree = "<group>";
}; };
E0DA8A9325E8F3C900425099 /* HLPrinter */ = {
isa = PBXGroup;
children = (
E0DA8A9425E8F3D800425099 /* HLBluetooth */,
E0DA8AA325E8F3D800425099 /* HLPrinter */,
E0DA8A9825E8F3D800425099 /* SVProgressHUD */,
);
path = HLPrinter;
sourceTree = "<group>";
};
E0DA8A9425E8F3D800425099 /* HLBluetooth */ = {
isa = PBXGroup;
children = (
E0DA8A9525E8F3D800425099 /* HLBLEConst.h */,
E0DA8A9625E8F3D800425099 /* HLBLEManager.m */,
E0DA8A9725E8F3D800425099 /* HLBLEManager.h */,
);
path = HLBluetooth;
sourceTree = "<group>";
};
E0DA8A9825E8F3D800425099 /* SVProgressHUD */ = {
isa = PBXGroup;
children = (
E0DA8A9925E8F3D800425099 /* SVRadialGradientLayer.m */,
E0DA8A9A25E8F3D800425099 /* SVIndefiniteAnimatedView.h */,
E0DA8A9B25E8F3D800425099 /* SVProgressHUD.h */,
E0DA8A9C25E8F3D800425099 /* SVProgressAnimatedView.m */,
E0DA8A9D25E8F3D800425099 /* SVProgressHUD-Prefix.pch */,
E0DA8A9E25E8F3D800425099 /* SVRadialGradientLayer.h */,
E0DA8A9F25E8F3D800425099 /* SVProgressHUD.m */,
E0DA8AA025E8F3D800425099 /* SVIndefiniteAnimatedView.m */,
E0DA8AA125E8F3D800425099 /* SVProgressHUD.bundle */,
E0DA8AA225E8F3D800425099 /* SVProgressAnimatedView.h */,
);
path = SVProgressHUD;
sourceTree = "<group>";
};
E0DA8AA325E8F3D800425099 /* HLPrinter */ = {
isa = PBXGroup;
children = (
E0DA8AA425E8F3D800425099 /* HLPrinter.m */,
E0DA8AA525E8F3D800425099 /* UIWebView+UIImage.m */,
E0DA8AA625E8F3D800425099 /* UIImage+Bitmap.h */,
E0DA8AA725E8F3D800425099 /* UIWebView+UIImage.h */,
E0DA8AA825E8F3D800425099 /* UIImage+Bitmap.m */,
E0DA8AA925E8F3D800425099 /* HLPrinter.h */,
);
path = HLPrinter;
sourceTree = "<group>";
};
E0DDCB0B244AD84500DF54C7 /* 订单管理 */ = { E0DDCB0B244AD84500DF54C7 /* 订单管理 */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -3745,6 +3801,7 @@ ...@@ -3745,6 +3801,7 @@
F96E48AA24CA9559000AB8D4 /* TitleTimeHeaderFooterView.xib in Resources */, F96E48AA24CA9559000AB8D4 /* TitleTimeHeaderFooterView.xib in Resources */,
E0706EF524B40BE800D8251C /* TitleAndTfYuanCell.xib in Resources */, E0706EF524B40BE800D8251C /* TitleAndTfYuanCell.xib in Resources */,
E0337EF22464F69000952EF4 /* YingFuZKListViewController.xib in Resources */, E0337EF22464F69000952EF4 /* YingFuZKListViewController.xib in Resources */,
E0DA8AAF25E8F3D800425099 /* SVProgressHUD.bundle in Resources */,
E002465324A8697B00049DBC /* TitleAndTFBtnCell.xib in Resources */, E002465324A8697B00049DBC /* TitleAndTFBtnCell.xib in Resources */,
E0B9462C2456AABE00FBEC9A /* YuShouWeiKuanFaHuoCell.xib in Resources */, E0B9462C2456AABE00FBEC9A /* YuShouWeiKuanFaHuoCell.xib in Resources */,
E0A2E81F24552F0A00D6DB34 /* TilteAndTextViewCell.xib in Resources */, E0A2E81F24552F0A00D6DB34 /* TilteAndTextViewCell.xib in Resources */,
...@@ -3837,6 +3894,7 @@ ...@@ -3837,6 +3894,7 @@
E0BE8A8C245A7D3300E80134 /* BtmBtnCell.xib in Resources */, E0BE8A8C245A7D3300E80134 /* BtmBtnCell.xib in Resources */,
F9D44E8424CBC50700FBD8DB /* WayBillAddressCanDelItemCell.xib in Resources */, F9D44E8424CBC50700FBD8DB /* WayBillAddressCanDelItemCell.xib in Resources */,
E007B1D9248F7276004D14CC /* CGDCell1.xib in Resources */, E007B1D9248F7276004D14CC /* CGDCell1.xib in Resources */,
E0DA8AD025E8F4C000425099 /* BtViewController.xib in Resources */,
E0DDCB1E244AE81800DF54C7 /* GuanLianKeHuCell.xib in Resources */, E0DDCB1E244AE81800DF54C7 /* GuanLianKeHuCell.xib in Resources */,
E077DC60255124B8000B0DA5 /* GYS_HZ_Vc.xib in Resources */, E077DC60255124B8000B0DA5 /* GYS_HZ_Vc.xib in Resources */,
E0DDCB14244ADF2C00DF54C7 /* ChangePriceNormalCell.xib in Resources */, E0DDCB14244ADF2C00DF54C7 /* ChangePriceNormalCell.xib in Resources */,
...@@ -3870,7 +3928,6 @@ ...@@ -3870,7 +3928,6 @@
E0336DD6244EC40000380BE9 /* CreatNewSpecsViewController.xib in Resources */, E0336DD6244EC40000380BE9 /* CreatNewSpecsViewController.xib in Resources */,
E0E7CB6224C17B9F00A26D3F /* GLKHCell.xib in Resources */, E0E7CB6224C17B9F00A26D3F /* GLKHCell.xib in Resources */,
E0C4F4B6244EE9EE00CC7E2F /* YuShouCell.xib in Resources */, E0C4F4B6244EE9EE00CC7E2F /* YuShouCell.xib in Resources */,
E0AC418125E88B0700805AE3 /* ConnectViewController.xib in Resources */,
F95A9EDE24557CD500867849 /* GuanLianKehuVC.xib in Resources */, F95A9EDE24557CD500867849 /* GuanLianKehuVC.xib in Resources */,
E07B1E6C245926330055BA3C /* GYSGLCell.xib in Resources */, E07B1E6C245926330055BA3C /* GYSGLCell.xib in Resources */,
E0974D5825C12DE100E3C86B /* one_title_cell.xib in Resources */, E0974D5825C12DE100E3C86B /* one_title_cell.xib in Resources */,
...@@ -3952,6 +4009,7 @@ ...@@ -3952,6 +4009,7 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
F956D5B7246A3255003FF510 /* OrderListModel.swift in Sources */, F956D5B7246A3255003FF510 /* OrderListModel.swift in Sources */,
E0DA8AB125E8F3D800425099 /* UIWebView+UIImage.m in Sources */,
E0A409C32463F31600CFF109 /* ShouZhiTongJiViewController.swift in Sources */, E0A409C32463F31600CFF109 /* ShouZhiTongJiViewController.swift in Sources */,
F950FDE624518B9500C40530 /* FSCalendarAppearance.m in Sources */, F950FDE624518B9500C40530 /* FSCalendarAppearance.m in Sources */,
E0974D6C25C140A600E3C86B /* S_Y_Detail_Vc.swift in Sources */, E0974D6C25C140A600E3C86B /* S_Y_Detail_Vc.swift in Sources */,
...@@ -3983,6 +4041,7 @@ ...@@ -3983,6 +4041,7 @@
E0A409CC2464026B00CFF109 /* SecondCell.swift in Sources */, E0A409CC2464026B00CFF109 /* SecondCell.swift in Sources */,
E0974D6525C12FAA00E3C86B /* scv_cell.swift in Sources */, E0974D6525C12FAA00E3C86B /* scv_cell.swift in Sources */,
E0BE8A87245A7A1500E80134 /* JiBenXinXiCell.swift in Sources */, E0BE8A87245A7A1500E80134 /* JiBenXinXiCell.swift in Sources */,
E0DA8AAD25E8F3D800425099 /* SVProgressHUD.m in Sources */,
E0DDCB13244ADF2C00DF54C7 /* ChangePriceNormalCell.swift in Sources */, E0DDCB13244ADF2C00DF54C7 /* ChangePriceNormalCell.swift in Sources */,
E0EABAE72487748500F6CA8D /* NewSelectWarehouseVC.swift in Sources */, E0EABAE72487748500F6CA8D /* NewSelectWarehouseVC.swift in Sources */,
F956D5B2246A2D9C003FF510 /* LMNDraft.m in Sources */, F956D5B2246A2D9C003FF510 /* LMNDraft.m in Sources */,
...@@ -4103,6 +4162,7 @@ ...@@ -4103,6 +4162,7 @@
F96A585024790E300070A057 /* TFHpple.m in Sources */, F96A585024790E300070A057 /* TFHpple.m in Sources */,
E027E36925B5686D00CBCA65 /* print_top_btn_cell.swift in Sources */, E027E36925B5686D00CBCA65 /* print_top_btn_cell.swift in Sources */,
E06B1AEC25B52725002F3C65 /* PrintViewController.swift in Sources */, E06B1AEC25B52725002F3C65 /* PrintViewController.swift in Sources */,
E0DA8AAB25E8F3D800425099 /* SVRadialGradientLayer.m in Sources */,
F9F2866724CA95FD00959142 /* TitleTimeHeaderFooterView.swift in Sources */, F9F2866724CA95FD00959142 /* TitleTimeHeaderFooterView.swift in Sources */,
F924B39024971BCB00A913CD /* CustomerInterface.swift in Sources */, F924B39024971BCB00A913CD /* CustomerInterface.swift in Sources */,
E0516F822448086700E373CE /* MsgCenterCell.swift in Sources */, E0516F822448086700E373CE /* MsgCenterCell.swift in Sources */,
...@@ -4117,6 +4177,7 @@ ...@@ -4117,6 +4177,7 @@
F950FDA32451438A00C40530 /* AdminInfoModel.swift in Sources */, F950FDA32451438A00C40530 /* AdminInfoModel.swift in Sources */,
E0D197D5244860B1002B080C /* BlueToothCell.swift in Sources */, E0D197D5244860B1002B080C /* BlueToothCell.swift in Sources */,
F961D27724503F51007FBE70 /* OrderSelectMoreView.swift in Sources */, F961D27724503F51007FBE70 /* OrderSelectMoreView.swift in Sources */,
E0DA8AAC25E8F3D800425099 /* SVProgressAnimatedView.m in Sources */,
F933F6C62452C68B00189561 /* PKHUDAssets.swift in Sources */, F933F6C62452C68B00189561 /* PKHUDAssets.swift in Sources */,
F976255C2552B392001EC5B0 /* DistributorSettingAlertView.swift in Sources */, F976255C2552B392001EC5B0 /* DistributorSettingAlertView.swift in Sources */,
F95D9B522448530E0080D6E3 /* GeliAlertView.swift in Sources */, F95D9B522448530E0080D6E3 /* GeliAlertView.swift in Sources */,
...@@ -4154,6 +4215,7 @@ ...@@ -4154,6 +4215,7 @@
F956D5A8246A2D9C003FF510 /* LMNSpecialLine.m in Sources */, F956D5A8246A2D9C003FF510 /* LMNSpecialLine.m in Sources */,
E0B530882472917F00FFCC15 /* ShopWarehouseDetailModel.swift in Sources */, E0B530882472917F00FFCC15 /* ShopWarehouseDetailModel.swift in Sources */,
F96E48A324CA79D4000AB8D4 /* WayBillAddressItemCell.swift in Sources */, F96E48A324CA79D4000AB8D4 /* WayBillAddressItemCell.swift in Sources */,
E0DA8AAA25E8F3D800425099 /* HLBLEManager.m in Sources */,
E0273DDD24551D4500B3FCAE /* OnlyLabelCell.swift in Sources */, E0273DDD24551D4500B3FCAE /* OnlyLabelCell.swift in Sources */,
F950FDD724518B9500C40530 /* FSCalendarCollectionView.m in Sources */, F950FDD724518B9500C40530 /* FSCalendarCollectionView.m in Sources */,
E077DC5F255124B8000B0DA5 /* GYS_HZ_Vc.swift in Sources */, E077DC5F255124B8000B0DA5 /* GYS_HZ_Vc.swift in Sources */,
...@@ -4162,6 +4224,7 @@ ...@@ -4162,6 +4224,7 @@
E07C2FFA24ECCD4D0043649B /* GLMessageAlertView.swift in Sources */, E07C2FFA24ECCD4D0043649B /* GLMessageAlertView.swift in Sources */,
E0A409D02464041200CFF109 /* ThirdCell.swift in Sources */, E0A409D02464041200CFF109 /* ThirdCell.swift in Sources */,
F956D59F246A2D9C003FF510 /* LMNPhotoCollectionCell.m in Sources */, F956D59F246A2D9C003FF510 /* LMNPhotoCollectionCell.m in Sources */,
E0DA8AAE25E8F3D800425099 /* SVIndefiniteAnimatedView.m in Sources */,
E0E5604F25C167220004BA56 /* Print_Gprinter_View.swift in Sources */, E0E5604F25C167220004BA56 /* Print_Gprinter_View.swift in Sources */,
F950FDE424518B9500C40530 /* FSCalendarTransitionCoordinator.m in Sources */, F950FDE424518B9500C40530 /* FSCalendarTransitionCoordinator.m in Sources */,
F9B6D9E12486890D00111698 /* MoreAndTimeSelectView.swift in Sources */, F9B6D9E12486890D00111698 /* MoreAndTimeSelectView.swift in Sources */,
...@@ -4235,6 +4298,7 @@ ...@@ -4235,6 +4298,7 @@
F9A4F24F24C9689600D1DD13 /* OtherDemandViewController.swift in Sources */, F9A4F24F24C9689600D1DD13 /* OtherDemandViewController.swift in Sources */,
F950FDD824518B9500C40530 /* FSCalendarDelegationProxy.m in Sources */, F950FDD824518B9500C40530 /* FSCalendarDelegationProxy.m in Sources */,
E01EA1A0245A5D6B00F019D5 /* YunDanXiangQingViewController.swift in Sources */, E01EA1A0245A5D6B00F019D5 /* YunDanXiangQingViewController.swift in Sources */,
E0DA8AB025E8F3D800425099 /* HLPrinter.m in Sources */,
E051EBD724A1F0ED00892DA9 /* CGDCell.swift in Sources */, E051EBD724A1F0ED00892DA9 /* CGDCell.swift in Sources */,
F9697248248F88C70010D39B /* GeliAltetCodeView.swift in Sources */, F9697248248F88C70010D39B /* GeliAltetCodeView.swift in Sources */,
F93615DB2480B421004187F9 /* WorkInterface.swift in Sources */, F93615DB2480B421004187F9 /* WorkInterface.swift in Sources */,
...@@ -4306,7 +4370,6 @@ ...@@ -4306,7 +4370,6 @@
E01E5484254FD34C00A2620C /* GYS_GuanLi_Cell.swift in Sources */, E01E5484254FD34C00A2620C /* GYS_GuanLi_Cell.swift in Sources */,
F9956B1E2463D94E001A617D /* WorkSelectTimeView.swift in Sources */, F9956B1E2463D94E001A617D /* WorkSelectTimeView.swift in Sources */,
E01313DB25C0048C006CFA5D /* Add_Report_View.swift in Sources */, E01313DB25C0048C006CFA5D /* Add_Report_View.swift in Sources */,
E0AC418025E88B0700805AE3 /* ConnectViewController.m in Sources */,
F9531F3B2465108800724BEE /* JXPhotoBrowserZoomSupportedCell.swift in Sources */, F9531F3B2465108800724BEE /* JXPhotoBrowserZoomSupportedCell.swift in Sources */,
F950FDE024518B9500C40530 /* FSCalendarExtensions.m in Sources */, F950FDE024518B9500C40530 /* FSCalendarExtensions.m in Sources */,
E09B03A32445AF9500211A51 /* NetworkRequest.swift in Sources */, E09B03A32445AF9500211A51 /* NetworkRequest.swift in Sources */,
...@@ -4321,6 +4384,7 @@ ...@@ -4321,6 +4384,7 @@
E00E48C22457C0D600F16545 /* XuanZeShangPinViewController.swift in Sources */, E00E48C22457C0D600F16545 /* XuanZeShangPinViewController.swift in Sources */,
F956D5BB246A359C003FF510 /* GoodsInterface.swift in Sources */, F956D5BB246A359C003FF510 /* GoodsInterface.swift in Sources */,
F91E9EBE2579D00900FAFCFA /* RetailListMgVC.swift in Sources */, F91E9EBE2579D00900FAFCFA /* RetailListMgVC.swift in Sources */,
E0DA8ACF25E8F4C000425099 /* BtViewController.m in Sources */,
E0BE8A83245A76AF00E80134 /* XiaDanCGDiZhiCell.swift in Sources */, E0BE8A83245A76AF00E80134 /* XiaDanCGDiZhiCell.swift in Sources */,
E042F730245272FF00CDFA12 /* XiaYunDanViewController.swift in Sources */, E042F730245272FF00CDFA12 /* XiaYunDanViewController.swift in Sources */,
E09B03A72445B04E00211A51 /* BaseViewController.swift in Sources */, E09B03A72445B04E00211A51 /* BaseViewController.swift in Sources */,
...@@ -4333,6 +4397,7 @@ ...@@ -4333,6 +4397,7 @@
E0B9461E24566B3100FBEC9A /* TitleAndTFAndBtnCell.swift in Sources */, E0B9461E24566B3100FBEC9A /* TitleAndTFAndBtnCell.swift in Sources */,
E042F74324529B7B00CDFA12 /* JiTuoWuXinXiView.swift in Sources */, E042F74324529B7B00CDFA12 /* JiTuoWuXinXiView.swift in Sources */,
F933F6CC2452C68B00189561 /* WindowRootViewController.swift in Sources */, F933F6CC2452C68B00189561 /* WindowRootViewController.swift in Sources */,
E0DA8AB225E8F3D800425099 /* UIImage+Bitmap.m in Sources */,
F956D5AE246A2D9C003FF510 /* LMNTextLine.m in Sources */, F956D5AE246A2D9C003FF510 /* LMNTextLine.m in Sources */,
F9531F442465108800724BEE /* JXPhotoBrowserFadeAnimator.swift in Sources */, F9531F442465108800724BEE /* JXPhotoBrowserFadeAnimator.swift in Sources */,
E007B1DB248F8F57004D14CC /* PurchaseInterface.swift in Sources */, E007B1DB248F8F57004D14CC /* PurchaseInterface.swift in Sources */,
......
...@@ -40,13 +40,13 @@ import ESTabBarController_swift ...@@ -40,13 +40,13 @@ import ESTabBarController_swift
@UIApplicationMain @UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate,loginDelegate,UITabBarControllerDelegate, JPUSHRegisterDelegate{ class AppDelegate: UIResponder, UIApplicationDelegate,loginDelegate,UITabBarControllerDelegate, JPUSHRegisterDelegate{
var blueToothVC:ConnectViewController! var blueToothVC:UIViewController!
var window:UIWindow? var window:UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// 启动图,调整展示时间为3秒 // 启动图,调整展示时间为3秒
Thread .sleep(forTimeInterval: 2.0) Thread .sleep(forTimeInterval: 2.0)
blueToothVC = ConnectViewController() blueToothVC = UIViewController()
let UserToken = UserDefaults.standard.value(forKey: "user_token") let UserToken = UserDefaults.standard.value(forKey: "user_token")
if UserToken == nil { if UserToken == nil {
......
{ {
"info" : { "info" : {
"version" : 1, "author" : "xcode",
"author" : "xcode" "version" : 1
} }
} }
\ No newline at end of file
{
"images" : [
{
"filename" : "chenggong.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "chenggong@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "chenggong@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
...@@ -26,10 +26,8 @@ ...@@ -26,10 +26,8 @@
#import "JZLocationConverter.h" #import "JZLocationConverter.h"
#import "CBController.h"
#import "DeviceInfo.h" #import "HLBLEManager.h"
#import "TscCommand.h" #import "SVProgressHUD.h"
#import "BLKWrite.h"
#import "EscCommand.h"
#import "ConnectViewController.h"
#endif /* Bridge_Header_h */ #endif /* Bridge_Header_h */
//
// HLBLEConst.h
// HLBluetoothDemo
//
// Created by Harvey on 16/4/29.
// Copyright © 2016年 Halley. All rights reserved.
//
#ifndef HLBLEConst_h
#define HLBLEConst_h
typedef NS_ENUM(NSInteger, HLOptionStage) {
HLOptionStageConnection, //蓝牙连接阶段
HLOptionStageSeekServices, //搜索服务阶段
HLOptionStageSeekCharacteristics, //搜索特性阶段
HLOptionStageSeekdescriptors, //搜索描述信息阶段
};
#pragma mark ------------------- 通知的定义 --------------------------
/** 蓝牙状态改变的通知 */
#define kCentralManagerStateUpdateNoticiation @"kCentralManagerStateUpdateNoticiation"
#pragma mark ------------------- block的定义 --------------------------
/** 蓝牙状态改变的block */
typedef void(^HLStateUpdateBlock)(CBCentralManager *central);
/** 发现一个蓝牙外设的block */
typedef void(^HLDiscoverPeripheralBlock)(CBCentralManager *central, CBPeripheral *peripheral, NSDictionary *advertisementData, NSNumber *RSSI);
/** 连接完成的block,失败error就不为nil */
typedef void(^HLConnectCompletionBlock)(CBPeripheral *peripheral, NSError *error);
/** 搜索到连接上的蓝牙外设的服务block */
typedef void(^HLDiscoveredServicesBlock)(CBPeripheral *peripheral, NSArray *services, NSError *error);
/** 搜索某个服务的子服务 的回调 */
typedef void(^HLDiscoveredIncludedServicesBlock)(CBPeripheral *peripheral,CBService *service, NSArray *includedServices, NSError *error);
/** 搜索到某个服务中的特性的block */
typedef void(^HLDiscoverCharacteristicsBlock)(CBPeripheral *peripheral, CBService *service, NSArray *characteristics, NSError *error);
/** 收到某个特性值更新的回调 */
typedef void(^HLNotifyCharacteristicBlock)(CBPeripheral *peripheral,CBCharacteristic *characteristic,NSError *error);
/** 查找到某个特性的描述 block */
typedef void(^HLDiscoverDescriptorsBlock)(CBPeripheral *peripheral,CBCharacteristic *characteristic,NSArray *descriptors, NSError *error);
/** 统一返回使用的block */
typedef void(^HLBLECompletionBlock)(HLOptionStage stage, CBPeripheral *peripheral,CBService *service, CBCharacteristic *character, NSError *error);
/** 获取特性中的值 */
typedef void(^HLValueForCharacteristicBlock)(CBCharacteristic *characteristic, NSData *value, NSError *error);
/** 获取描述中的值 */
typedef void(^HLValueForDescriptorBlock)(CBDescriptor *descriptor,NSData *data,NSError *error);
/** 往特性中写入数据的回调 */
typedef void(^HLWriteToCharacteristicBlock)(CBCharacteristic *characteristic, NSError *error);
/** 往描述中写入数据的回调 */
typedef void(^HLWriteToDescriptorBlock)(CBDescriptor *descriptor, NSError *error);
/** 获取蓝牙外设信号的回调 */
typedef void(^HLGetRSSIBlock)(CBPeripheral *peripheral,NSNumber *RSSI, NSError *error);
#endif /* HLBLEConst_h */
//
// HLBLEManager.h
// HLBluetoothDemo
//
// Created by Harvey on 16/4/27.
// Copyright © 2016年 Halley. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import "HLBLEConst.h"
@interface HLBLEManager : NSObject
#pragma mark - properties
/** 蓝牙模块状态改变的回调 */
@property (copy, nonatomic) HLStateUpdateBlock stateUpdateBlock;
/** 发现一个蓝牙外设的回调 */
@property (copy, nonatomic) HLDiscoverPeripheralBlock discoverPeripheralBlcok;
/** 连接外设完成的回调 */
@property (copy, nonatomic) HLConnectCompletionBlock connectCompleteBlock;
/** 发现服务的回调 */
@property (copy, nonatomic) HLDiscoveredServicesBlock discoverServicesBlock;
/** 发现服务中的特性的回调 */
@property (copy, nonatomic) HLDiscoverCharacteristicsBlock discoverCharacteristicsBlock;
/** 特性值改变的回调 */
@property (copy, nonatomic) HLNotifyCharacteristicBlock notifyCharacteristicBlock;
/** 发现服务中的子服务的回调 */
@property (copy, nonatomic) HLDiscoveredIncludedServicesBlock discoverdIncludedServicesBlock;
/** 发现特性的描述的回调 */
@property (copy, nonatomic) HLDiscoverDescriptorsBlock discoverDescriptorsBlock;
/** 操作完成的统一回调 */
@property (copy, nonatomic) HLBLECompletionBlock completionBlock;
/** 获取特性值回调 */
@property (copy, nonatomic) HLValueForCharacteristicBlock valueForCharacteristicBlock;
/** 获取描述值的回调 */
@property (copy, nonatomic) HLValueForDescriptorBlock valueForDescriptorBlock;
/** 将数据写入特性中的回调 */
@property (copy, nonatomic) HLWriteToCharacteristicBlock writeToCharacteristicBlock;
/** 将数据写入描述中的回调*/
@property (copy, nonatomic) HLWriteToDescriptorBlock writeToDescriptorBlock;
/** 获取蓝牙外设信号强度的回调 */
@property (copy, nonatomic) HLGetRSSIBlock getRSSIBlock;
@property (strong, nonatomic, readonly) CBPeripheral *connectedPerpheral; /**< 当前连接的外设 */
/**
* 每次发送的最大数据长度,因为部分型号的蓝牙打印机一次写入数据过长,会导致打印乱码。
* iOS 9之后,会调用系统的API来获取特性能写入的最大数据长度。
* 但是iOS 9之前需要自己测试然后设置一个合适的值。默认值是146,我使用佳博58MB-III的限度。
* 所以,如果你打印乱码,你考虑将该值设置小一点再试试。
*/
@property (assign, nonatomic) NSInteger limitLength;
#pragma mark - method
+ (instancetype)sharedInstance;
/**
* 开始搜索蓝牙外设,每次在block中返回一个蓝牙外设信息
*
* @param uuids 服务的CBUUID
* @param option 其他可选参数
*/
- (void)scanForPeripheralsWithServiceUUIDs:(NSArray<CBUUID *> *)uuids options:(NSDictionary<NSString *, id> *)options;
/**
* 开始搜索蓝牙外设,每次在block中返回一个蓝牙外设信息
* 返回的block参数可参考CBCentralManager 的 centralManager:didDiscoverPeripheral:advertisementData:RSSI:
*
* @param uuids 服务的CBUUID
* @param option 其他可选参数
* @param discoverBlock 搜索到蓝牙外设后的回调
*/
- (void)scanForPeripheralsWithServiceUUIDs:(NSArray<CBUUID *> *)uuids options:(NSDictionary<NSString *, id> *)options didDiscoverPeripheral:(HLDiscoverPeripheralBlock)discoverBlock;
/**
* 连接某个蓝牙外设,并查询服务,特性,特性描述
*
* @param peripheral 要连接的蓝牙外设
* @param connectOptions 连接的配置参数
* @param stop 连接成功后是否停止搜索蓝牙外设
* @param serviceUUIDs 要搜索的服务UUID
* @param characteristicUUIDs 要搜索的特性UUID
* @param completionBlock 操作执行完的回调
*/
- (void)connectPeripheral:(CBPeripheral *)peripheral
connectOptions:(NSDictionary<NSString *,id> *)connectOptions
stopScanAfterConnected:(BOOL)stop
servicesOptions:(NSArray<CBUUID *> *)serviceUUIDs
characteristicsOptions:(NSArray<CBUUID *> *)characteristicUUIDs
completeBlock:(HLBLECompletionBlock)completionBlock;
/**
* 查找某个服务的子服务
*
* @param includedServiceUUIDs 要查找的子服务的UUIDs
* @param service 父服务
*/
- (void)discoverIncludedServices:(NSArray<CBUUID *> *)includedServiceUUIDs forService:(CBService *)service;
/**
* 读取某个特性的值
*
* @param characteristic 要读取的特性
*/
- (void)readValueForCharacteristic:(CBCharacteristic *)characteristic;
/**
* 读取某个特性的值
*
* @param characteristic 要读取的特性
* @param completionBlock 读取完后的回调
*/
- (void)readValueForCharacteristic:(CBCharacteristic *)characteristic completionBlock:(HLValueForCharacteristicBlock)completionBlock;
/**
* 往某个特性中写入数据
*
* @param data 写入的数据
* @param characteristic 特性对象
* @param type 写入类型
*/
- (void)writeValue:(NSData *)data forCharacteristic:(CBCharacteristic *)characteristic type:(CBCharacteristicWriteType)type;
/**
* 往某个特性中写入数据
*
* @param data 写入的数据
* @param characteristic 特性对象
* @param type 写入类型
* @param completionBlock 写入完成后的回调,只有type为CBCharacteristicWriteWithResponse时,才会回调
*/
- (void)writeValue:(NSData *)data forCharacteristic:(CBCharacteristic *)characteristic type:(CBCharacteristicWriteType)type completionBlock:(HLWriteToCharacteristicBlock)completionBlock;
/**
* 读取某特性的描述信息
*
* @param descriptor 描述对象
*/
- (void)readValueForDescriptor:(CBDescriptor *)descriptor;
/**
* 读取某特性的描述信息
*
* @param descriptor 描述对象
* @param completionBlock 读取结果返回时的回调
*/
- (void)readValueForDescriptor:(CBDescriptor *)descriptor completionBlock:(HLValueForDescriptorBlock)completionBlock;
/**
* 将数据写入特性的描述中
*
* @param data 数据
* @param descriptor 描述对象
*/
- (void)writeValue:(NSData *)data forDescriptor:(CBDescriptor *)descriptor;
/**
* 将数据写入特性的描述中
*
* @param data 数据
* @param descriptor 描述对象
* @param completionBlock 数据写入完成后的回调
*/
- (void)writeValue:(NSData *)data forDescriptor:(CBDescriptor *)descriptor completionBlock:(HLWriteToDescriptorBlock)completionBlock;
/**
* 获取某外设的信号
*
* @param completionBlock 获取信号完成后的回调
*/
- (void)readRSSICompletionBlock:(HLGetRSSIBlock)getRSSIBlock;
/**
* 停止扫描
*/
- (void)stopScan;
/**
* 断开蓝牙连接
*/
- (void)cancelPeripheralConnection;
@end
//
// HLBLEManager.m
// HLBluetoothDemo
//
// Created by Harvey on 16/4/27.
// Copyright © 2016年 Halley. All rights reserved.
//
#import "HLBLEManager.h"
// 发送数据时,需要分段的长度,部分打印机一次发送数据过长就会乱码,需要分段发送。这个长度值不同的打印机可能不一样,你需要调试设置一个合适的值(最好是偶数)
#define kLimitLength 146
@interface HLBLEManager ()<CBCentralManagerDelegate,CBPeripheralDelegate>
@property (strong, nonatomic) CBCentralManager *centralManager; /**< 中心管理器 */
@property (strong, nonatomic) CBPeripheral *connectedPerpheral; /**< 当前连接的外设 */
@property (strong, nonatomic) NSArray<CBUUID *> *serviceUUIDs; /**< 要查找服务的UUIDs */
@property (strong, nonatomic) NSArray<CBUUID *> *characteristicUUIDs; /**< 要查找特性的UUIDs */
@property (assign, nonatomic) BOOL stopScanAfterConnected; /**< 是否连接成功后停止扫描蓝牙设备 */
@property (assign, nonatomic) NSInteger writeCount; /**< 写入次数 */
@property (assign, nonatomic) NSInteger responseCount; /**< 返回次数 */
@end
static HLBLEManager *instance = nil;
@implementation HLBLEManager
+ (instancetype)sharedInstance
{
return [[self alloc] init];
}
- (instancetype)init {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance = [super init];
//蓝牙没打开时alert提示框
NSDictionary *options = @{CBCentralManagerOptionShowPowerAlertKey:@(YES)};
_centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:dispatch_get_main_queue() options:options];
_limitLength = kLimitLength;
});
return instance;
}
+ (instancetype)allocWithZone:(struct _NSZone *)zone
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance = [super allocWithZone:zone];
});
return instance;
}
- (void)scanForPeripheralsWithServiceUUIDs:(NSArray<CBUUID *> *)uuids options:(NSDictionary<NSString *, id> *)options
{
[_centralManager scanForPeripheralsWithServices:uuids options:options];
}
- (void)scanForPeripheralsWithServiceUUIDs:(NSArray<CBUUID *> *)uuids options:(NSDictionary<NSString *, id> *)options didDiscoverPeripheral:(HLDiscoverPeripheralBlock)discoverBlock
{
_discoverPeripheralBlcok = discoverBlock;
[_centralManager scanForPeripheralsWithServices:uuids options:options];
}
- (void)connectPeripheral:(CBPeripheral *)peripheral
connectOptions:(NSDictionary<NSString *,id> *)connectOptions
stopScanAfterConnected:(BOOL)stop
servicesOptions:(NSArray<CBUUID *> *)serviceUUIDs
characteristicsOptions:(NSArray<CBUUID *> *)characteristicUUIDs
completeBlock:(HLBLECompletionBlock)completionBlock;
{
//1.保存回调的block以及参数
_completionBlock = completionBlock;
_serviceUUIDs = serviceUUIDs;
_characteristicUUIDs = characteristicUUIDs;
_stopScanAfterConnected = stop;
//2.先取消之前连接的蓝牙外设
if (_connectedPerpheral) {
[_centralManager cancelPeripheralConnection:_connectedPerpheral];
}
//3.开始连接新的蓝牙外设
[_centralManager connectPeripheral:peripheral options:connectOptions];
//4.设置代理
peripheral.delegate = self;
}
- (void)discoverIncludedServices:(NSArray<CBUUID *> *)includedServiceUUIDs forService:(CBService *)service
{
[_connectedPerpheral discoverIncludedServices:includedServiceUUIDs forService:service];
}
- (void)stopScan
{
[_centralManager stopScan];
_discoverPeripheralBlcok = nil;
}
- (void)cancelPeripheralConnection
{
if (_connectedPerpheral) {
[_centralManager cancelPeripheralConnection:_connectedPerpheral];
}
}
- (void)readValueForCharacteristic:(CBCharacteristic *)characteristic
{
[_connectedPerpheral readValueForCharacteristic:characteristic];
}
- (void)readValueForCharacteristic:(CBCharacteristic *)characteristic completionBlock:(HLValueForCharacteristicBlock)completionBlock
{
_valueForCharacteristicBlock = completionBlock;
[self readValueForCharacteristic:characteristic];
}
- (void)writeValue:(NSData *)data forCharacteristic:(CBCharacteristic *)characteristic type:(CBCharacteristicWriteType)type
{
_writeCount = 0;
_responseCount = 0;
// iOS 9 以后,系统添加了这个API来获取特性能写入的最大长度
if ([_connectedPerpheral respondsToSelector:@selector(maximumWriteValueLengthForType:)]) {
_limitLength = [_connectedPerpheral maximumWriteValueLengthForType:type];
}
// 如果_limitLength 小于等于0,则表示不用分段发送
if (_limitLength <= 0) {
[_connectedPerpheral writeValue:data forCharacteristic:characteristic type:type];
_writeCount ++;
return;
}
if (data.length <= _limitLength) {
[_connectedPerpheral writeValue:data forCharacteristic:characteristic type:type];
_writeCount ++;
} else {
NSInteger index = 0;
for (index = 0; index < data.length - _limitLength; index += _limitLength) {
NSData *subData = [data subdataWithRange:NSMakeRange(index, _limitLength)];
[_connectedPerpheral writeValue:subData forCharacteristic:characteristic type:type];
_writeCount++;
}
NSData *leftData = [data subdataWithRange:NSMakeRange(index, data.length - index)];
if (leftData) {
[_connectedPerpheral writeValue:leftData forCharacteristic:characteristic type:type];
_writeCount++;
}
}
}
- (void)writeValue:(NSData *)data forCharacteristic:(CBCharacteristic *)characteristic type:(CBCharacteristicWriteType)type completionBlock:(HLWriteToCharacteristicBlock)completionBlock
{
_writeToCharacteristicBlock = completionBlock;
[self writeValue:data forCharacteristic:characteristic type:type];
}
- (void)readValueForDescriptor:(CBDescriptor *)descriptor
{
[_connectedPerpheral readValueForDescriptor:descriptor];
}
- (void)readValueForDescriptor:(CBDescriptor *)descriptor completionBlock:(HLValueForDescriptorBlock)completionBlock
{
_valueForDescriptorBlock = completionBlock;
[self readValueForDescriptor:descriptor];
}
- (void)writeValue:(NSData *)data forDescriptor:(CBDescriptor *)descriptor
{
[_connectedPerpheral writeValue:data forDescriptor:descriptor];
}
- (void)writeValue:(NSData *)data forDescriptor:(CBDescriptor *)descriptor completionBlock:(HLWriteToDescriptorBlock)completionBlock
{
_writeToDescriptorBlock = completionBlock;
[self writeValue:data forDescriptor:descriptor];
}
- (void)readRSSICompletionBlock:(HLGetRSSIBlock)getRSSIBlock
{
_getRSSIBlock = getRSSIBlock;
[_connectedPerpheral readRSSI];
}
#pragma mark - CBCentralManagerDelegate
- (void)centralManagerDidUpdateState:(CBCentralManager *)central
{
[[NSNotificationCenter defaultCenter] postNotificationName:kCentralManagerStateUpdateNoticiation object:@{@"central":central}];
if (_stateUpdateBlock) {
_stateUpdateBlock(central);
}
}
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary<NSString *, id> *)advertisementData RSSI:(NSNumber *)RSSI
{
if (_discoverPeripheralBlcok) {
_discoverPeripheralBlcok(central, peripheral, advertisementData, RSSI);
}
}
#pragma mark ---------------- 连接外设成功和失败的代理 ---------------
- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral
{
_connectedPerpheral = peripheral;
if (_stopScanAfterConnected) {
[_centralManager stopScan];
}
if (_discoverServicesBlock) {
_discoverServicesBlock(peripheral, peripheral.services,nil);
}
if (_completionBlock) {
_completionBlock(HLOptionStageConnection,peripheral,nil,nil,nil);
}
[peripheral discoverServices:_serviceUUIDs];
}
- (void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral *)peripheral error:(nullable NSError *)error
{
if (_discoverServicesBlock) {
_discoverServicesBlock(peripheral, peripheral.services,error);
}
if (_completionBlock) {
_completionBlock(HLOptionStageConnection,peripheral,nil,nil,error);
}
}
- (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)peripheral error:(nullable NSError *)error
{
_connectedPerpheral = nil;
NSLog(@"断开连接了,断开连接了 %@",error);
}
#pragma mark ---------------- 发现服务的代理 -----------------
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(nullable NSError *)error
{
if (error) {
if (_completionBlock) {
_completionBlock(HLOptionStageSeekServices,peripheral,nil,nil,error);
}
return;
}
if (_completionBlock) {
_completionBlock(HLOptionStageSeekServices,peripheral,nil,nil,nil);
}
for (CBService *service in peripheral.services) {
[peripheral discoverCharacteristics:_characteristicUUIDs forService:service];
}
}
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverIncludedServicesForService:(CBService *)service error:(nullable NSError *)error
{
if (error) {
if (_discoverdIncludedServicesBlock) {
_discoverdIncludedServicesBlock(peripheral,service,nil,error);
}
return;
}
if (_discoverdIncludedServicesBlock) {
_discoverdIncludedServicesBlock(peripheral,service,service.includedServices,error);
}
}
#pragma mark ---------------- 服务特性的代理 --------------------
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(nullable NSError *)error
{
if (error) {
if (_completionBlock) {
_completionBlock(HLOptionStageSeekCharacteristics,peripheral,service,nil,error);
}
return;
}
if (_discoverCharacteristicsBlock) {
_discoverCharacteristicsBlock(peripheral,service,service.characteristics,nil);
}
if (_completionBlock) {
_completionBlock(HLOptionStageSeekCharacteristics,peripheral,service,nil,nil);
}
for (CBCharacteristic *character in service.characteristics) {
[peripheral discoverDescriptorsForCharacteristic:character];
[peripheral readValueForCharacteristic:character];
}
}
- (void)peripheral:(CBPeripheral *)peripheral didUpdateNotificationStateForCharacteristic:(CBCharacteristic *)characteristic error:(nullable NSError *)error
{
if (error) {
if (_notifyCharacteristicBlock) {
_notifyCharacteristicBlock(peripheral,characteristic,error);
}
return;
}
if (_notifyCharacteristicBlock) {
_notifyCharacteristicBlock(peripheral,characteristic,nil);
}
}
// 读取特性中的值
- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
{
if (error) {
if (_valueForCharacteristicBlock) {
_valueForCharacteristicBlock(characteristic,nil,error);
}
return;
}
//
NSData *data = characteristic.value;
// if (data.length > 0) {
// const unsigned char *hexBytesLight = [data bytes];
//
// NSString * battery = [NSString stringWithFormat:@"%02x", hexBytesLight[0]];
//
// NSLog(@"batteryInfo:%@",battery);
// }
if (_valueForCharacteristicBlock) {
_valueForCharacteristicBlock(characteristic,data,nil);
}
}
#pragma mark ---------------- 发现服务特性描述的代理 ------------------
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverDescriptorsForCharacteristic:(CBCharacteristic *)characteristic error:(nullable NSError *)error
{
if (error) {
if (_completionBlock) {
_completionBlock(HLOptionStageSeekdescriptors,peripheral,nil,characteristic,error);
}
return;
}
if (_completionBlock) {
_completionBlock(HLOptionStageSeekdescriptors,peripheral,nil,characteristic,nil);
}
}
- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForDescriptor:(CBDescriptor *)descriptor error:(nullable NSError *)error
{
if (error) {
if (_valueForDescriptorBlock) {
_valueForDescriptorBlock(descriptor,nil,error);
}
return;
}
NSData *data = descriptor.value;
if (_valueForDescriptorBlock) {
_valueForDescriptorBlock(descriptor,data,nil);
}
}
- (void)peripheral:(CBPeripheral *)peripheral didWriteValueForDescriptor:(CBDescriptor *)descriptor error:(nullable NSError *)error
{
if (error) {
if (_writeToDescriptorBlock) {
_writeToDescriptorBlock(descriptor, error);
}
return;
}
if (_writeToDescriptorBlock) {
_writeToDescriptorBlock(descriptor, nil);
}
}
#pragma mark ---------------- 写入数据的回调 --------------------
- (void)peripheral:(CBPeripheral *)peripheral didWriteValueForCharacteristic:(CBCharacteristic *)characteristic error:(nullable NSError *)error
{
if (!_writeToCharacteristicBlock) {
return;
}
_responseCount ++;
if (_writeCount != _responseCount) {
return;
}
_writeToCharacteristicBlock(characteristic,error);
}
#pragma mark ---------------- 获取信号之后的回调 ------------------
# if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_0
- (void)peripheralDidUpdateRSSI:(CBPeripheral *)peripheral error:(nullable NSError *)error {
if (_getRSSIBlock) {
_getRSSIBlock(peripheral,peripheral.RSSI,error);
}
}
#else
- (void)peripheral:(CBPeripheral *)peripheral didReadRSSI:(NSNumber *)RSSI error:(NSError *)error {
if (_getRSSIBlock) {
_getRSSIBlock(peripheral,RSSI,error);
}
}
#endif
@end
//
// HLPrinter.h
// HLBluetoothDemo
//
// Created by Harvey on 16/5/3.
// Copyright © 2016年 Halley. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "UIImage+Bitmap.h"
typedef NS_ENUM(NSInteger, HLPrinterStyle) {
HLPrinterStyleDefault,
HLPrinterStyleCustom
};
/** 文字对齐方式 */
typedef NS_ENUM(NSInteger, HLTextAlignment) {
HLTextAlignmentLeft = 0x00,
HLTextAlignmentCenter = 0x01,
HLTextAlignmentRight = 0x02
};
/** 字号 */
typedef NS_ENUM(NSInteger, HLFontSize) {
HLFontSizeTitleSmalle = 0x00,
HLFontSizeTitleMiddle = 0x11,
HLFontSizeTitleBig = 0x22
};
@interface HLPrinter : NSObject
/**
* 添加单行标题,默认字号是小号字体
*
* @param title 标题名称
* @param alignment 标题对齐方式
*/
- (void)appendText:(NSString *)text alignment:(HLTextAlignment)alignment;
/**
* 添加单行标题
*
* @param title 标题名称
* @param alignment 标题对齐方式
* @param fontSize 标题字号
*/
- (void)appendText:(NSString *)text alignment:(HLTextAlignment)alignment fontSize:(HLFontSize)fontSize;
/**
* 添加单行信息,左边名称(左对齐),右边实际值(右对齐),默认字号是小号。
* @param title 名称
* @param value 实际值
* 警告:因字号和字体与iOS中字体不一致,计算出来有误差,可以用[-appendTitle:value:valueOffset:]或[-appendTitle:value:valueOffset:fontSize:]
*/
- (void)appendTitle:(NSString *)title value:(NSString *)value;
/**
* 添加单行信息,左边名称(左对齐),右边实际值(右对齐)。
* @param title 名称
* @param value 实际值
* @param fontSize 字号大小
* 警告:因字号和字体与iOS中字体不一致,计算出来有误差,所以建议用在价格方面
*/
- (void)appendTitle:(NSString *)title value:(NSString *)value fontSize:(HLFontSize)fontSize;
/**
* 设置单行信息,左标题,右实际值
* @提醒 该方法的预览效果与实际效果误差较大,请以实际打印小票为准
*
* @param title 标题
* @param value 实际值
* @param offset 实际值偏移量
*/
- (void)appendTitle:(NSString *)title value:(NSString *)value valueOffset:(NSInteger)offset;
/**
* 设置单行信息,左标题,右实际值
* @提醒 该方法的预览效果与实际效果误差较大,请以实际打印小票为准
*
* @param title 标题
* @param value 实际值
* @param offset 实际值偏移量
* @param fontSize 字号
*/
- (void)appendTitle:(NSString *)title value:(NSString *)value valueOffset:(NSInteger)offset fontSize:(HLFontSize)fontSize;
/**
* 添加选购商品信息标题,一般是三列,名称、数量、单价
*
* @param LeftText 左标题
* @param middleText 中间标题
* @param rightText 右标题
*/
- (void)appendLeftText:(NSString *)left middleText:(NSString *)middle rightText:(NSString *)right isTitle:(BOOL)isTitle;
/**
* 添加图片,一般是添加二维码或者条形码
* ⚠️提醒:这种打印图片的方式,是自己生成图片,然后用位图打印
*
* @param image 图片
* @param alignment 图片对齐方式
* @param maxWidth 图片的最大宽度,如果图片过大,会等比缩放
*/
- (void)appendImage:(UIImage *)image alignment:(HLTextAlignment)alignment maxWidth:(CGFloat)maxWidth;
/**
* 添加条形码图片
* ⚠️提醒:这种打印条形码的方式,是自己生成条形码图片,然后用位图打印图片
*
* @param info 条形码中包含的信息,默认居中显示,最大宽度为300。如果大于300,会等比缩放。
*/
- (void)appendBarCodeWithInfo:(NSString *)info;
/**
* 添加条形码图片
* ⚠️提醒:这种打印条形码的方式,是自己生成条形码图片,然后用位图打印图片
*
* @param info 条形码中的信息
* @param alignment 图片对齐方式
* @param maxWidth 图片最大宽度
*/
- (void)appendBarCodeWithInfo:(NSString *)info alignment:(HLTextAlignment)alignment maxWidth:(CGFloat)maxWidth;
/**
* 添加二维码
* ✅推荐:这种方式使用的是打印机的指令生成二维码并打印机,所以比较推荐这种方式
*
* @param info 二维码中的信息
* @param size 二维码的大小 取值范围1 <= size <= 16
*/
- (void)appendQRCodeWithInfo:(NSString *)info size:(NSInteger)size;
/**
* 添加二维码
* ✅推荐:这种方式使用的是打印机的指令生成二维码并打印机,所以比较推荐这种方式
*
* @param info 二维码中的信息
* @param size 二维码大小,取值范围 1 <= size <= 16
* @param alignment 设置图片对齐方式
*/
- (void)appendQRCodeWithInfo:(NSString *)info size:(NSInteger)size alignment:(HLTextAlignment)alignment;
/**
* 添加二维码图片
* ⚠️提醒:这种打印条二维码的方式,是自己生成二维码图片,然后用位图打印图片
*
* @param info 二维码中的信息
*/
- (void)appendQRCodeWithInfo:(NSString *)info;
/**
* 添加二维码图片
* ⚠️提醒:这种打印条二维码的方式,是自己生成二维码图片,然后用位图打印图片
*
* @param info 二维码中的信息
* @param centerImage 二维码中间的图片
* @param alignment 对齐方式
* @param maxWidth 二维码的最大宽度
*/
- (void)appendQRCodeWithInfo:(NSString *)info centerImage:(UIImage *)centerImage alignment:(HLTextAlignment)alignment maxWidth:(CGFloat )maxWidth;
/**
* 添加一条分割线,like this:---------------------------
*/
- (void)appendSeperatorLine;
/**
* 添加底部信息
*
* @param footerInfo 不填默认为 谢谢惠顾,欢迎下次光临!
*/
- (void)appendFooter:(NSString *)footerInfo;
/**
添加自定义的data
@param data 自定义的data
*/
- (void)appendCustomData:(NSData *)data;
/**
* 获取最终的data
*
* @return 最终的data
*/
- (NSData *)getFinalData;
@end
//
// HLPrinter.m
// HLBluetoothDemo
//
// Created by Harvey on 16/5/3.
// Copyright © 2016年 Halley. All rights reserved.
//
#import "HLPrinter.h"
#define kHLMargin 20
#define kHLPadding 2
#define kHLPreviewWidth 320
@interface HLPrinter ()
/** 将要打印的排版后的数据 */
@property (strong, nonatomic) NSMutableData *printerData;
@end
@implementation HLPrinter
- (instancetype)init
{
self = [super init];
if (self) {
[self defaultSetting];
}
return self;
}
- (void)defaultSetting
{
_printerData = [[NSMutableData alloc] init];
// 1.初始化打印机
Byte initBytes[] = {0x1B,0x40};
[_printerData appendBytes:initBytes length:sizeof(initBytes)];
// 2.设置行间距为1/6英寸,约34个点
// 另一种设置行间距的方法看这个 @link{-setLineSpace:}
Byte lineSpace[] = {0x1B,0x32};
[_printerData appendBytes:lineSpace length:sizeof(lineSpace)];
// 3.设置字体:标准0x00,压缩0x01;
Byte fontBytes[] = {0x1B,0x4D,0x00};
[_printerData appendBytes:fontBytes length:sizeof(fontBytes)];
}
#pragma mark - -------------基本操作----------------
/**
* 换行
*/
- (void)appendNewLine
{
Byte nextRowBytes[] = {0x0A};
[_printerData appendBytes:nextRowBytes length:sizeof(nextRowBytes)];
}
/**
* 回车
*/
- (void)appendReturn
{
Byte returnBytes[] = {0x0D};
[_printerData appendBytes:returnBytes length:sizeof(returnBytes)];
}
/**
* 设置对齐方式
*
* @param alignment 对齐方式:居左、居中、居右
*/
- (void)setAlignment:(HLTextAlignment)alignment
{
Byte alignBytes[] = {0x1B,0x61,alignment};
[_printerData appendBytes:alignBytes length:sizeof(alignBytes)];
}
/**
* 设置字体大小
*
* @param fontSize 字号
*/
- (void)setFontSize:(HLFontSize)fontSize
{
Byte fontSizeBytes[] = {0x1D,0x21,fontSize};
[_printerData appendBytes:fontSizeBytes length:sizeof(fontSizeBytes)];
}
/**
* 添加文字,不换行
*
* @param text 文字内容
*/
- (void)setText:(NSString *)text
{
NSStringEncoding enc = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000);
NSData *data = [text dataUsingEncoding:enc];
[_printerData appendData:data];
}
/**
* 添加文字,不换行
*
* @param text 文字内容
* @param maxChar 最多可以允许多少个字节,后面加...
*/
- (void)setText:(NSString *)text maxChar:(int)maxChar
{
NSStringEncoding enc = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000);
NSData *data = [text dataUsingEncoding:enc];
if (data.length > maxChar) {
data = [data subdataWithRange:NSMakeRange(0, maxChar)];
text = [[NSString alloc] initWithData:data encoding:enc];
if (!text) {
data = [data subdataWithRange:NSMakeRange(0, maxChar - 1)];
text = [[NSString alloc] initWithData:data encoding:enc];
}
text = [text stringByAppendingString:@"..."];
}
[self setText:text];
}
/**
* 设置偏移文字
*
* @param text 文字
*/
- (void)setOffsetText:(NSString *)text
{
// 1.计算偏移量,因字体和字号不同,所以计算出来的宽度与实际宽度有误差(小字体与22字体计算值接近)
NSDictionary *dict = @{NSFontAttributeName:[UIFont systemFontOfSize:22.0]};
NSAttributedString *valueAttr = [[NSAttributedString alloc] initWithString:text attributes:dict];
int valueWidth = valueAttr.size.width;
// 2.设置偏移量
[self setOffset:368 - valueWidth];
// 3.设置文字
[self setText:text];
}
/**
* 设置偏移量
*
* @param offset 偏移量
*/
- (void)setOffset:(NSInteger)offset
{
NSInteger remainder = offset % 256;
NSInteger consult = offset / 256;
Byte spaceBytes2[] = {0x1B, 0x24, remainder, consult};
[_printerData appendBytes:spaceBytes2 length:sizeof(spaceBytes2)];
}
/**
* 设置行间距
*
* @param points 多少个点
*/
- (void)setLineSpace:(NSInteger)points
{
//最后一位,可选 0~255
Byte lineSpace[] = {0x1B,0x33,points};
[_printerData appendBytes:lineSpace length:sizeof(lineSpace)];
}
/**
* 设置二维码模块大小
*
* @param size 1<= size <= 16,二维码的宽高相等
*/
- (void)setQRCodeSize:(NSInteger)size
{
Byte QRSize [] = {0x1D,0x28,0x6B,0x03,0x00,0x31,0x43,size};
// Byte QRSize [] = {29,40,107,3,0,49,67,size};
[_printerData appendBytes:QRSize length:sizeof(QRSize)];
}
/**
* 设置二维码的纠错等级
*
* @param level 48 <= level <= 51
*/
- (void)setQRCodeErrorCorrection:(NSInteger)level
{
Byte levelBytes [] = {0x1D,0x28,0x6B,0x03,0x00,0x31,0x45,level};
// Byte levelBytes [] = {29,40,107,3,0,49,69,level};
[_printerData appendBytes:levelBytes length:sizeof(levelBytes)];
}
/**
* 将二维码数据存储到符号存储区
* [范围]: 4≤(pL+pH×256)≤7092 (0≤pL≤255,0≤pH≤27)
* cn=49
* fn=80
* m=48
* k=(pL+pH×256)-3, k就是数据的长度
*
* @param info 二维码数据
*/
- (void)setQRCodeInfo:(NSString *)info
{
NSInteger kLength = info.length + 3;
NSInteger pL = kLength % 256;
NSInteger pH = kLength / 256;
Byte dataBytes [] = {0x1D,0x28,0x6B,pL,pH,0x31,0x50,48};
// Byte dataBytes [] = {29,40,107,pL,pH,49,80,48};
[_printerData appendBytes:dataBytes length:sizeof(dataBytes)];
NSData *infoData = [info dataUsingEncoding:NSUTF8StringEncoding];
[_printerData appendData:infoData];
// [self setText:info];
}
/**
* 打印之前存储的二维码信息
*/
- (void)printStoredQRData
{
Byte printBytes [] = {0x1D,0x28,0x6B,0x03,0x00,0x31,0x51,48};
// Byte printBytes [] = {29,40,107,3,0,49,81,48};
[_printerData appendBytes:printBytes length:sizeof(printBytes)];
}
#pragma mark - ------------function method ----------------
#pragma mark 文字
- (void)appendText:(NSString *)text alignment:(HLTextAlignment)alignment
{
[self appendText:text alignment:alignment fontSize:HLFontSizeTitleSmalle];
}
- (void)appendText:(NSString *)text alignment:(HLTextAlignment)alignment fontSize:(HLFontSize)fontSize
{
// 1.文字对齐方式
[self setAlignment:alignment];
// 2.设置字号
[self setFontSize:fontSize];
// 3.设置标题内容
[self setText:text];
// 4.换行
[self appendNewLine];
if (fontSize != HLFontSizeTitleSmalle) {
[self appendNewLine];
}
}
- (void)appendTitle:(NSString *)title value:(NSString *)value
{
[self appendTitle:title value:value fontSize:HLFontSizeTitleSmalle];
}
- (void)appendTitle:(NSString *)title value:(NSString *)value fontSize:(HLFontSize)fontSize
{
// 1.设置对齐方式
[self setAlignment:HLTextAlignmentLeft];
// 2.设置字号
[self setFontSize:fontSize];
// 3.设置标题内容
[self setText:title];
// 4.设置实际值
[self setOffsetText:value];
// 5.换行
[self appendNewLine];
if (fontSize != HLFontSizeTitleSmalle) {
[self appendNewLine];
}
}
- (void)appendTitle:(NSString *)title value:(NSString *)value valueOffset:(NSInteger)offset
{
[self appendTitle:title value:value valueOffset:offset fontSize:HLFontSizeTitleSmalle];
}
- (void)appendTitle:(NSString *)title value:(NSString *)value valueOffset:(NSInteger)offset fontSize:(HLFontSize)fontSize
{
// 1.设置对齐方式
[self setAlignment:HLTextAlignmentLeft];
// 2.设置字号
[self setFontSize:fontSize];
// 3.设置标题内容
[self setText:title];
// 4.设置内容偏移量
[self setOffset:offset];
// 5.设置实际值
[self setText:value];
// 6.换行
[self appendNewLine];
if (fontSize != HLFontSizeTitleSmalle) {
[self appendNewLine];
}
}
- (void)appendLeftText:(NSString *)left middleText:(NSString *)middle rightText:(NSString *)right isTitle:(BOOL)isTitle
{
[self setAlignment:HLTextAlignmentLeft];
[self setFontSize:HLFontSizeTitleSmalle];
NSInteger offset = 0;
if (!isTitle) {
offset = 10;
}
if (left) {
[self setText:left maxChar:10];
}
if (middle) {
[self setOffset:150 + offset];
[self setText:middle];
}
if (right) {
[self setOffset:300 + offset];
[self setText:right];
}
[self appendNewLine];
}
#pragma mark 图片
- (void)appendImage:(UIImage *)image alignment:(HLTextAlignment)alignment maxWidth:(CGFloat)maxWidth
{
if (!image) {
return;
}
// 1.设置图片对齐方式
[self setAlignment:alignment];
// 2.设置图片
UIImage *newImage = [image imageWithscaleMaxWidth:maxWidth];
// newImage = [newImage blackAndWhiteImage];
NSData *imageData = [newImage bitmapData];
[_printerData appendData:imageData];
// 3.换行
[self appendNewLine];
// 4.打印图片后,恢复文字的行间距
Byte lineSpace[] = {0x1B,0x32};
[_printerData appendBytes:lineSpace length:sizeof(lineSpace)];
}
- (void)appendBarCodeWithInfo:(NSString *)info
{
[self appendBarCodeWithInfo:info alignment:HLTextAlignmentCenter maxWidth:300];
}
- (void)appendBarCodeWithInfo:(NSString *)info alignment:(HLTextAlignment)alignment maxWidth:(CGFloat)maxWidth
{
UIImage *barImage = [UIImage barCodeImageWithInfo:info];
[self appendImage:barImage alignment:alignment maxWidth:maxWidth];
}
- (void)appendQRCodeWithInfo:(NSString *)info size:(NSInteger)size
{
[self appendQRCodeWithInfo:info size:size alignment:HLTextAlignmentCenter];
}
- (void)appendQRCodeWithInfo:(NSString *)info size:(NSInteger)size alignment:(HLTextAlignment)alignment
{
[self setAlignment:alignment];
[self setQRCodeSize:size];
[self setQRCodeErrorCorrection:48];
[self setQRCodeInfo:info];
[self printStoredQRData];
[self appendNewLine];
}
- (void)appendQRCodeWithInfo:(NSString *)info
{
[self appendQRCodeWithInfo:info centerImage:nil alignment:HLTextAlignmentCenter maxWidth:250];
}
- (void)appendQRCodeWithInfo:(NSString *)info centerImage:(UIImage *)centerImage alignment:(HLTextAlignment)alignment maxWidth:(CGFloat )maxWidth
{
UIImage *QRImage = [UIImage qrCodeImageWithInfo:info centerImage:centerImage width:maxWidth];
[self appendImage:QRImage alignment:alignment maxWidth:maxWidth];
}
/**
添加自定义的data
@param data 自定义的data
*/
- (void)appendCustomData:(NSData *)data
{
if (data.length <= 0) {
return;
}
[_printerData appendData:data];
}
#pragma mark 其他
- (void)appendSeperatorLine
{
// 1.设置分割线居中
[self setAlignment:HLTextAlignmentCenter];
// 2.设置字号
[self setFontSize:HLFontSizeTitleSmalle];
// 3.添加分割线
NSString *line = @"- - - - - - - - - - - - - - - -";
NSStringEncoding enc = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000);
NSData *data = [line dataUsingEncoding:enc];
[_printerData appendData:data];
// 4.换行
[self appendNewLine];
}
- (void)appendFooter:(NSString *)footerInfo
{
[self appendSeperatorLine];
if (!footerInfo) {
footerInfo = @"谢谢惠顾,欢迎下次光临!";
}
[self appendText:footerInfo alignment:HLTextAlignmentCenter];
}
- (NSData *)getFinalData
{
return _printerData;
}
@end
//
// UIImage+Bitmap.h
// HLBluetoothDemo
//
// Created by Harvey on 16/5/3.
// Copyright © 2016年 Halley. All rights reserved.
//
#import <UIKit/UIKit.h>
typedef NS_ENUM(NSInteger,BitPixels) {
BPAlpha = 0,
BPBlue = 1,
BPGreen = 2,
BPRed = 3
};
@interface UIImage (Bitmap)
/**
* 将图片转换为点阵图数据
*
* @return 转化后的点阵图数据
*/
- (NSData *)bitmapData;
/**
* 将图片绘制到绘图上下文中,并返回上下文
*
* @return
*/
//+ (CGContextRef)bitmapRGBA8ContextFromImage:(CGImageRef)image;
- (CGContextRef)bitmapRGBA8Context;
/**
* 缩放图片,会按照给定的最大宽度,等比缩放
*
* @param maxWidth 缩放后的最大宽度
*
* @return 返回缩放后的图片
*/
- (UIImage *)imageWithscaleMaxWidth:(CGFloat)maxWidth;
/**
* 将图片转换为黑白图片
*
* @return 黑白图片
*/
- (UIImage *)blackAndWhiteImage;
@end
#pragma mark - -----------制作二维码 条形码------------
@interface UIImage (QRCode)
/**
* 创建条形码
*
* @param info 字符串信息
*
* @return 条形码图片
*/
+ (UIImage *)barCodeImageWithInfo:(NSString *)info;
/**
* 创建二维码
*
* @param info 二维码内的信息
* @param image 二维码中心的logo图片
* @param width 二维码的宽度
*
* @return 二维码图片
*/
+ (UIImage *)qrCodeImageWithInfo:(NSString *)info centerImage:(UIImage *)image width:(CGFloat)width;
/**
* 将CIImage 放大显示,并转换为UIImage。
*
* @param image 原始CIImage
* @param size 最终尺寸的宽度
*
* @return UIImage
*/
+ (UIImage *)createNonInterpolatedUIImageFormCIImage:(CIImage *)image withSize:(CGFloat)size;
/**
* 将原图转变为背景色透明,图片为设置的颜色
*
* @param image 要改变的图片
* @param red red
* @param green green
* @param blue blue
*
* @return 返回修改后的图片
*/
+ (UIImage*)imageBgColorToTransparentWith:(UIImage*)image withRed:(CGFloat)red andGreen:(CGFloat)green andBlue:(CGFloat)blue;
@end
//
// UIImage+Bitmap.m
// HLBluetoothDemo
//
// Created by Harvey on 16/5/3.
// Copyright © 2016年 Halley. All rights reserved.
//
#import "UIImage+Bitmap.h"
#import <AVFoundation/AVFoundation.h>
@implementation UIImage (Bitmap)
//
- (NSData *)bitmapData
{
CGImageRef imageRef = self.CGImage;
// Create a bitmap context to draw the uiimage into
CGContextRef context = [self bitmapRGBA8Context];
if(!context) {
return nil;
}
size_t width = CGImageGetWidth(imageRef);
size_t height = CGImageGetHeight(imageRef);
CGRect rect = CGRectMake(0, 0, width, height);
// Draw image into the context to get the raw image data
CGContextDrawImage(context, rect, imageRef);
// Get a pointer to the data
uint32_t *bitmapData = (uint32_t *)CGBitmapContextGetData(context);
if(bitmapData) {
uint8_t *m_imageData = (uint8_t *) malloc(width * height/8 + 8*height/8);
memset(m_imageData, 0, width * height/8 + 8*height/8);
int result_index = 0;
for(int y = 0; (y + 24) < height; ) {
m_imageData[result_index++] = 27;
m_imageData[result_index++] = 51;
m_imageData[result_index++] = 0;
m_imageData[result_index++] = 27;
m_imageData[result_index++] = 42;
m_imageData[result_index++] = 33;
m_imageData[result_index++] = width%256;
m_imageData[result_index++] = width/256;
for(int x = 0; x < width; x++) {
int value = 0;
for (int temp_y = 0 ; temp_y < 8; ++temp_y)
{
uint8_t *rgbaPixel = (uint8_t *) &bitmapData[(y+temp_y) * width + x];
uint32_t gray = 0.3 * rgbaPixel[BPRed] + 0.59 * rgbaPixel[BPGreen] + 0.11 * rgbaPixel[BPBlue];
if (gray < 127)
{
value += 1<<(7-temp_y)&255;
}
}
m_imageData[result_index++] = value;
value = 0;
for (int temp_y = 8 ; temp_y < 16; ++temp_y)
{
uint8_t *rgbaPixel = (uint8_t *) &bitmapData[(y+temp_y) * width + x];
uint32_t gray = 0.3 * rgbaPixel[BPRed] + 0.59 * rgbaPixel[BPGreen] + 0.11 * rgbaPixel[BPBlue];
if (gray < 127)
{
value += 1<<(7-temp_y%8)&255;
}
}
m_imageData[result_index++] = value;
value = 0;
for (int temp_y = 16 ; temp_y < 24; ++temp_y)
{
uint8_t *rgbaPixel = (uint8_t *) &bitmapData[(y+temp_y) * width + x];
uint32_t gray = 0.3 * rgbaPixel[BPRed] + 0.59 * rgbaPixel[BPGreen] + 0.11 * rgbaPixel[BPBlue];
if (gray < 127)
{
value += 1<<(7-temp_y%8)&255;
}
}
m_imageData[result_index++] = value;
}
m_imageData[result_index++] = 13;
m_imageData[result_index++] = 10;
y += 24;
}
NSMutableData *data = [[NSMutableData alloc] initWithCapacity:0];
[data appendBytes:m_imageData length:result_index];
free(bitmapData);
return data;
}
NSLog(@"Error getting bitmap pixel data\n");
CGContextRelease(context);
return nil ;
}
- (CGContextRef)bitmapRGBA8Context
{
CGImageRef imageRef = self.CGImage;
if (!imageRef) {
return NULL;
}
CGContextRef context = NULL;
CGColorSpaceRef colorSpace;
uint32_t *bitmapData;
size_t bitsPerPixel = 32;
size_t bitsPerComponent = 8;
size_t bytesPerPixel = bitsPerPixel / bitsPerComponent;
size_t width = CGImageGetWidth(imageRef);
size_t height = CGImageGetHeight(imageRef);
size_t bytesPerRow = width * bytesPerPixel;
size_t bufferLength = bytesPerRow * height;
colorSpace = CGColorSpaceCreateDeviceRGB();
if(!colorSpace) {
NSLog(@"Error allocating color space RGB\n");
return NULL;
}
// Allocate memory for image data
bitmapData = (uint32_t *)malloc(bufferLength);
if(!bitmapData) {
NSLog(@"Error allocating memory for bitmap\n");
CGColorSpaceRelease(colorSpace);
return NULL;
}
//Create bitmap context
context = CGBitmapContextCreate(bitmapData,
width,
height,
bitsPerComponent,
bytesPerRow,
colorSpace,
kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedLast); // RGBA
if(!context) {
free(bitmapData);
NSLog(@"Bitmap context not created");
}
CGColorSpaceRelease(colorSpace);
return context;
}
- (UIImage *)imageWithscaleMaxWidth:(CGFloat)maxWidth
{
CGFloat width = self.size.width;
if (width > maxWidth)
{
CGFloat height = self.size.height;
CGFloat maxHeight = maxWidth * height / width;
CGSize size = CGSizeMake(maxWidth, maxHeight);
UIGraphicsBeginImageContext(size);
[self drawInRect:CGRectMake(0, 0, maxWidth, maxHeight)];
UIImage *resultImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return resultImage;
}
return self;
}
- (UIImage *)blackAndWhiteImage
{
// CGSize size = self.size;
CIImage *beginImage = [CIImage imageWithCGImage:self.CGImage];
CIFilter *filter = [CIFilter filterWithName:@"CIColorMonochrome"
keysAndValues:kCIInputImageKey,beginImage,kCIInputColorKey,[CIColor colorWithCGColor:[UIColor blackColor].CGColor],nil];
CIImage *outputImage = [filter outputImage];
CIContext *context = [CIContext contextWithOptions:nil];
CGImageRef imageRef = [context createCGImage:outputImage fromRect:outputImage.extent];
UIImage *newImage = [UIImage imageWithCGImage:imageRef];
// UIImage *newImage = [UIImage createNonInterpolatedUIImageFormCIImage:outputImage withSize:size.width];
return newImage;
}
@end
@implementation UIImage (QRCode)
+ (UIImage *)barCodeImageWithInfo:(NSString *)info
{
// 创建条形码
CIFilter *filter = [CIFilter filterWithName:@"CICode128BarcodeGenerator"];
// 恢复滤镜的默认属性
[filter setDefaults];
// 将字符串转换成NSData
NSData *data = [info dataUsingEncoding:NSUTF8StringEncoding];
// 通过KVO设置滤镜inputMessage数据
[filter setValue:data forKey:@"inputMessage"];
// 获得滤镜输出的图像
CIImage *outputImage = [filter outputImage];
// 将CIImage转换成UIImage,并放大显示
UIImage *image =[self createNonInterpolatedUIImageFormCIImage:outputImage withSize:300];
return image;
}
+ (UIImage *)qrCodeImageWithInfo:(NSString *)info centerImage:(UIImage *)centerImage width:(CGFloat)width
{
if (!info) {
return nil;
}
NSData *strData = [info dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:NO];
//创建二维码滤镜
CIFilter *qrFilter = [CIFilter filterWithName:@"CIQRCodeGenerator"];
[qrFilter setValue:strData forKey:@"inputMessage"];
[qrFilter setValue:@"H" forKey:@"inputCorrectionLevel"];
CIImage *qrImage = qrFilter.outputImage;
UIImage *codeImage = [UIImage createNonInterpolatedUIImageFormCIImage:qrImage withSize:width];
//二维码rect
CGRect rect = CGRectMake(0, 0, codeImage.size.width, codeImage.size.height);
UIGraphicsBeginImageContext(rect.size);
[codeImage drawInRect:rect];
//定制logo
if (centerImage) {
//icon尺寸,UIBezierPath
CGSize logoSize = CGSizeMake(rect.size.width*0.2, rect.size.height*0.2);
CGFloat x = CGRectGetMidX(rect) - logoSize.width*0.5;
CGFloat y = CGRectGetMidY(rect) - logoSize.height*0.5;
CGRect logoFrame = CGRectMake(x, y, logoSize.width, logoSize.height);
[[UIBezierPath bezierPathWithRoundedRect:logoFrame cornerRadius:10] addClip];
[centerImage drawInRect:logoFrame];
}
UIImage *resultImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return resultImage;
}
+ (UIImage *)createNonInterpolatedUIImageFormCIImage:(CIImage *)image withSize:(CGFloat)size
{
CGRect extent = CGRectIntegral(image.extent);
CGFloat scale = MIN(size/CGRectGetWidth(extent), size/CGRectGetHeight(extent));
// 创建bitmap;
size_t width = CGRectGetWidth(extent) * scale;
size_t height = CGRectGetHeight(extent) * scale;
CGColorSpaceRef cs = CGColorSpaceCreateDeviceGray();
CGContextRef bitmapRef = CGBitmapContextCreate(nil, width, height, 8, 0, cs, (CGBitmapInfo)kCGImageAlphaNone);
CIContext *context = [CIContext contextWithOptions:nil];
CGImageRef bitmapImage = [context createCGImage:image fromRect:extent];
CGContextSetInterpolationQuality(bitmapRef, kCGInterpolationNone);
CGContextScaleCTM(bitmapRef, scale, scale);
CGContextDrawImage(bitmapRef, extent, bitmapImage);
// 保存bitmap到图片
CGImageRef scaledImage = CGBitmapContextCreateImage(bitmapRef);
CGContextRelease(bitmapRef);
CGImageRelease(bitmapImage);
return [UIImage imageWithCGImage:scaledImage];
}
void ProviderReleaseData (void *info, const void *data, size_t size){
free((void*)data);
}
+ (UIImage*)imageBgColorToTransparentWith:(UIImage*)image withRed:(CGFloat)red andGreen:(CGFloat)green andBlue:(CGFloat)blue{
const int imageWidth = image.size.width;
const int imageHeight = image.size.height;
size_t bytesPerRow = imageWidth * 4;
uint32_t* rgbImageBuf = (uint32_t*)malloc(bytesPerRow * imageHeight);
// create context
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(rgbImageBuf, imageWidth, imageHeight, 8, bytesPerRow, colorSpace,
kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipLast);
CGContextDrawImage(context, CGRectMake(0, 0, imageWidth, imageHeight), image.CGImage);
// traverse pixe
int pixelNum = imageWidth * imageHeight;
uint32_t* pCurPtr = rgbImageBuf;
for (int i = 0; i < pixelNum; i++, pCurPtr++){
if ((*pCurPtr & 0xFFFFFF00) < 0x99999900){
// change color
uint8_t* ptr = (uint8_t*)pCurPtr;
ptr[3] = red; //0~255
ptr[2] = green;
ptr[1] = blue;
}else{
uint8_t* ptr = (uint8_t*)pCurPtr;
ptr[0] = 0;
}
}
// context to image
CGDataProviderRef dataProvider = CGDataProviderCreateWithData(NULL, rgbImageBuf, bytesPerRow * imageHeight, ProviderReleaseData);
CGImageRef imageRef = CGImageCreate(imageWidth, imageHeight, 8, 32, bytesPerRow, colorSpace,
kCGImageAlphaLast | kCGBitmapByteOrder32Little, dataProvider,
NULL, true, kCGRenderingIntentDefault);
CGDataProviderRelease(dataProvider);
UIImage* resultUIImage = [UIImage imageWithCGImage:imageRef];
// release
CGImageRelease(imageRef);
CGContextRelease(context);
CGColorSpaceRelease(colorSpace);
return resultUIImage;
}
@end
//
// UIWebView+UIImage.h
// HLBluetoothDemo
//
// Created by Harvey on 16/5/13.
// Copyright © 2016年 Halley. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIWebView (UIImage)
/**
* 获取当前加载的网页的截图
*
* @return
*/
- (UIImage *)imageForWebView;
@end
//
// UIWebView+UIImage.m
// HLBluetoothDemo
//
// Created by Harvey on 16/5/13.
// Copyright © 2016年 Halley. All rights reserved.
//
#import <QuartzCore/QuartzCore.h>
#import "UIWebView+UIImage.h"
@implementation UIWebView (UIImage)
/**
* 获取当前加载的网页的截图
* 获取当前WebView的size,然后一屏一屏的截图后,再拼接成一张完整的图片
*
* @return
*/
- (UIImage *)imageForWebView
{
// 1.获取WebView的宽高
CGSize boundsSize = self.bounds.size;
CGFloat boundsWidth = boundsSize.width;
CGFloat boundsHeight = boundsSize.height;
// 2.获取contentSize
CGSize contentSize = self.scrollView.contentSize;
CGFloat contentHeight = contentSize.height;
// 3.保存原始偏移量,便于截图后复位
CGPoint offset = self.scrollView.contentOffset;
// 4.设置最初的偏移量为(0,0);
[self.scrollView setContentOffset:CGPointMake(0, 0)];
NSMutableArray *images = [NSMutableArray array];
while (contentHeight > 0) {
// 5.获取CGContext 5.获取CGContext
UIGraphicsBeginImageContextWithOptions(boundsSize, NO, 0.0);
CGContextRef ctx = UIGraphicsGetCurrentContext();
// 6.渲染要截取的区域
[self.layer renderInContext:ctx];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// 7.截取的图片保存起来
[images addObject:image];
CGFloat offsetY = self.scrollView.contentOffset.y;
[self.scrollView setContentOffset:CGPointMake(0, offsetY + boundsHeight)];
contentHeight -= boundsHeight;
}
// 8 webView 恢复到之前的显示区域
[self.scrollView setContentOffset:offset];
CGFloat scale = [UIScreen mainScreen].scale;
CGSize imageSize = CGSizeMake(contentSize.width * scale,
contentSize.height * scale);
// 9.根据设备的分辨率重新绘制、拼接成完整清晰图片
UIGraphicsBeginImageContext(imageSize);
[images enumerateObjectsUsingBlock:^(UIImage *image, NSUInteger idx, BOOL *stop) {
[image drawInRect:CGRectMake(0,
scale * boundsHeight * idx,
scale * boundsWidth,
scale * boundsHeight)];
}];
UIImage *fullImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return fullImage;
}
@end
//
// SVIndefiniteAnimatedView.h
// SVProgressHUD, https://github.com/SVProgressHUD/SVProgressHUD
//
// Copyright (c) 2014-2016 Guillaume Campagna. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface SVIndefiniteAnimatedView : UIView
@property (nonatomic, assign) CGFloat strokeThickness;
@property (nonatomic, assign) CGFloat radius;
@property (nonatomic, strong) UIColor *strokeColor;
@end
//
// SVIndefiniteAnimatedView.m
// SVProgressHUD, https://github.com/SVProgressHUD/SVProgressHUD
//
// Copyright (c) 2014-2016 Guillaume Campagna. All rights reserved.
//
#import "SVIndefiniteAnimatedView.h"
#import "SVProgressHUD.h"
@interface SVIndefiniteAnimatedView ()
@property (nonatomic, strong) CAShapeLayer *indefiniteAnimatedLayer;
@end
@implementation SVIndefiniteAnimatedView
- (void)willMoveToSuperview:(UIView*)newSuperview {
if (newSuperview) {
[self layoutAnimatedLayer];
} else {
[_indefiniteAnimatedLayer removeFromSuperlayer];
_indefiniteAnimatedLayer = nil;
}
}
- (void)layoutAnimatedLayer {
CALayer *layer = self.indefiniteAnimatedLayer;
[self.layer addSublayer:layer];
CGFloat widthDiff = CGRectGetWidth(self.bounds) - CGRectGetWidth(layer.bounds);
CGFloat heightDiff = CGRectGetHeight(self.bounds) - CGRectGetHeight(layer.bounds);
layer.position = CGPointMake(CGRectGetWidth(self.bounds) - CGRectGetWidth(layer.bounds) / 2 - widthDiff / 2, CGRectGetHeight(self.bounds) - CGRectGetHeight(layer.bounds) / 2 - heightDiff / 2);
}
- (CAShapeLayer*)indefiniteAnimatedLayer {
if(!_indefiniteAnimatedLayer) {
CGPoint arcCenter = CGPointMake(self.radius+self.strokeThickness/2+5, self.radius+self.strokeThickness/2+5);
UIBezierPath* smoothedPath = [UIBezierPath bezierPathWithArcCenter:arcCenter radius:self.radius startAngle:(CGFloat) (M_PI*3/2) endAngle:(CGFloat) (M_PI/2+M_PI*5) clockwise:YES];
_indefiniteAnimatedLayer = [CAShapeLayer layer];
_indefiniteAnimatedLayer.contentsScale = [[UIScreen mainScreen] scale];
_indefiniteAnimatedLayer.frame = CGRectMake(0.0f, 0.0f, arcCenter.x*2, arcCenter.y*2);
_indefiniteAnimatedLayer.fillColor = [UIColor clearColor].CGColor;
_indefiniteAnimatedLayer.strokeColor = self.strokeColor.CGColor;
_indefiniteAnimatedLayer.lineWidth = self.strokeThickness;
_indefiniteAnimatedLayer.lineCap = kCALineCapRound;
_indefiniteAnimatedLayer.lineJoin = kCALineJoinBevel;
_indefiniteAnimatedLayer.path = smoothedPath.CGPath;
CALayer *maskLayer = [CALayer layer];
NSBundle *bundle = [NSBundle bundleForClass:[SVProgressHUD class]];
NSURL *url = [bundle URLForResource:@"SVProgressHUD" withExtension:@"bundle"];
NSBundle *imageBundle = [NSBundle bundleWithURL:url];
NSString *path = [imageBundle pathForResource:@"angle-mask" ofType:@"png"];
maskLayer.contents = (__bridge id)[[UIImage imageWithContentsOfFile:path] CGImage];
maskLayer.frame = _indefiniteAnimatedLayer.bounds;
_indefiniteAnimatedLayer.mask = maskLayer;
NSTimeInterval animationDuration = 1;
CAMediaTimingFunction *linearCurve = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
animation.fromValue = (id) 0;
animation.toValue = @(M_PI*2);
animation.duration = animationDuration;
animation.timingFunction = linearCurve;
animation.removedOnCompletion = NO;
animation.repeatCount = INFINITY;
animation.fillMode = kCAFillModeForwards;
animation.autoreverses = NO;
[_indefiniteAnimatedLayer.mask addAnimation:animation forKey:@"rotate"];
CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
animationGroup.duration = animationDuration;
animationGroup.repeatCount = INFINITY;
animationGroup.removedOnCompletion = NO;
animationGroup.timingFunction = linearCurve;
CABasicAnimation *strokeStartAnimation = [CABasicAnimation animationWithKeyPath:@"strokeStart"];
strokeStartAnimation.fromValue = @0.015;
strokeStartAnimation.toValue = @0.515;
CABasicAnimation *strokeEndAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
strokeEndAnimation.fromValue = @0.485;
strokeEndAnimation.toValue = @0.985;
animationGroup.animations = @[strokeStartAnimation, strokeEndAnimation];
[_indefiniteAnimatedLayer addAnimation:animationGroup forKey:@"progress"];
}
return _indefiniteAnimatedLayer;
}
- (void)setFrame:(CGRect)frame {
if(!CGRectEqualToRect(frame, super.frame)) {
[super setFrame:frame];
if(self.superview) {
[self layoutAnimatedLayer];
}
}
}
- (void)setRadius:(CGFloat)radius {
if(radius != _radius) {
_radius = radius;
[_indefiniteAnimatedLayer removeFromSuperlayer];
_indefiniteAnimatedLayer = nil;
if(self.superview) {
[self layoutAnimatedLayer];
}
}
}
- (void)setStrokeColor:(UIColor*)strokeColor {
_strokeColor = strokeColor;
_indefiniteAnimatedLayer.strokeColor = strokeColor.CGColor;
}
- (void)setStrokeThickness:(CGFloat)strokeThickness {
_strokeThickness = strokeThickness;
_indefiniteAnimatedLayer.lineWidth = _strokeThickness;
}
- (CGSize)sizeThatFits:(CGSize)size {
return CGSizeMake((self.radius+self.strokeThickness/2+5)*2, (self.radius+self.strokeThickness/2+5)*2);
}
@end
//
// SVProgressAnimatedView.h
// SVProgressHUD, https://github.com/SVProgressHUD/SVProgressHUD
//
// Copyright (c) 2016 Tobias Tiemerding. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface SVProgressAnimatedView : UIView
@property (nonatomic, assign) CGFloat radius;
@property (nonatomic, assign) CGFloat strokeThickness;
@property (nonatomic, strong) UIColor *strokeColor;
@property (nonatomic, assign) CGFloat strokeEnd;
@end
//
// SVProgressAnimatedView.m
// SVProgressHUD, https://github.com/SVProgressHUD/SVProgressHUD
//
// Copyright (c) 2016 Tobias Tiemerding. All rights reserved.
//
#import "SVProgressAnimatedView.h"
@interface SVProgressAnimatedView ()
@property (nonatomic, strong) CAShapeLayer *ringAnimatedLayer;
@end
@implementation SVProgressAnimatedView
- (void)willMoveToSuperview:(UIView*)newSuperview {
if (newSuperview) {
[self layoutAnimatedLayer];
} else {
[_ringAnimatedLayer removeFromSuperlayer];
_ringAnimatedLayer = nil;
}
}
- (void)layoutAnimatedLayer {
CALayer *layer = self.ringAnimatedLayer;
[self.layer addSublayer:layer];
CGFloat widthDiff = CGRectGetWidth(self.bounds) - CGRectGetWidth(layer.bounds);
CGFloat heightDiff = CGRectGetHeight(self.bounds) - CGRectGetHeight(layer.bounds);
layer.position = CGPointMake(CGRectGetWidth(self.bounds) - CGRectGetWidth(layer.bounds) / 2 - widthDiff / 2, CGRectGetHeight(self.bounds) - CGRectGetHeight(layer.bounds) / 2 - heightDiff / 2);
}
- (CAShapeLayer*)ringAnimatedLayer {
if(!_ringAnimatedLayer) {
CGPoint arcCenter = CGPointMake(self.radius+self.strokeThickness/2+5, self.radius+self.strokeThickness/2+5);
UIBezierPath* smoothedPath = [UIBezierPath bezierPathWithArcCenter:arcCenter radius:self.radius startAngle:(CGFloat)-M_PI_2 endAngle:(CGFloat) (M_PI + M_PI_2) clockwise:YES];
_ringAnimatedLayer = [CAShapeLayer layer];
_ringAnimatedLayer.contentsScale = [[UIScreen mainScreen] scale];
_ringAnimatedLayer.frame = CGRectMake(0.0f, 0.0f, arcCenter.x*2, arcCenter.y*2);
_ringAnimatedLayer.fillColor = [UIColor clearColor].CGColor;
_ringAnimatedLayer.strokeColor = self.strokeColor.CGColor;
_ringAnimatedLayer.lineWidth = self.strokeThickness;
_ringAnimatedLayer.lineCap = kCALineCapRound;
_ringAnimatedLayer.lineJoin = kCALineJoinBevel;
_ringAnimatedLayer.path = smoothedPath.CGPath;
}
return _ringAnimatedLayer;
}
- (void)setFrame:(CGRect)frame {
if(!CGRectEqualToRect(frame, super.frame)) {
[super setFrame:frame];
if(self.superview) {
[self layoutAnimatedLayer];
}
}
}
- (void)setRadius:(CGFloat)radius {
if(radius != _radius) {
_radius = radius;
[_ringAnimatedLayer removeFromSuperlayer];
_ringAnimatedLayer = nil;
if(self.superview) {
[self layoutAnimatedLayer];
}
}
}
- (void)setStrokeColor:(UIColor*)strokeColor {
_strokeColor = strokeColor;
_ringAnimatedLayer.strokeColor = strokeColor.CGColor;
}
- (void)setStrokeThickness:(CGFloat)strokeThickness {
_strokeThickness = strokeThickness;
_ringAnimatedLayer.lineWidth = _strokeThickness;
}
- (void)setStrokeEnd:(CGFloat)strokeEnd {
_strokeEnd = strokeEnd;
_ringAnimatedLayer.strokeEnd = _strokeEnd;
}
- (CGSize)sizeThatFits:(CGSize)size {
return CGSizeMake((self.radius+self.strokeThickness/2+5)*2, (self.radius+self.strokeThickness/2+5)*2);
}
@end
//
// Prefix header for all source files of the 'SVProgressHUD' target in the 'SVProgressHUD' project
//
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#endif
//
// SVProgressHUD.h
// SVProgressHUD, https://github.com/SVProgressHUD/SVProgressHUD
//
// Copyright (c) 2011-2016 Sam Vermette and contributors. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <AvailabilityMacros.h>
#if __IPHONE_OS_VERSION_MAX_ALLOWED < 70000
#define UI_APPEARANCE_SELECTOR
#endif
extern NSString * const SVProgressHUDDidReceiveTouchEventNotification;
extern NSString * const SVProgressHUDDidTouchDownInsideNotification;
extern NSString * const SVProgressHUDWillDisappearNotification;
extern NSString * const SVProgressHUDDidDisappearNotification;
extern NSString * const SVProgressHUDWillAppearNotification;
extern NSString * const SVProgressHUDDidAppearNotification;
extern NSString * const SVProgressHUDStatusUserInfoKey;
typedef NS_ENUM(NSInteger, SVProgressHUDStyle) {
SVProgressHUDStyleLight, // default style, white HUD with black text, HUD background will be blurred on iOS 8 and above
SVProgressHUDStyleDark, // black HUD and white text, HUD background will be blurred on iOS 8 and above
SVProgressHUDStyleCustom // uses the fore- and background color properties
};
typedef NS_ENUM(NSUInteger, SVProgressHUDMaskType) {
SVProgressHUDMaskTypeNone = 1, // default mask type, allow user interactions while HUD is displayed
SVProgressHUDMaskTypeClear, // don't allow user interactions
SVProgressHUDMaskTypeBlack, // don't allow user interactions and dim the UI in the back of the HUD, as on iOS 7 and above
SVProgressHUDMaskTypeGradient, // don't allow user interactions and dim the UI with a a-la UIAlertView background gradient, as on iOS 6
SVProgressHUDMaskTypeCustom // don't allow user interactions and dim the UI in the back of the HUD with a custom color
};
typedef NS_ENUM(NSUInteger, SVProgressHUDAnimationType) {
SVProgressHUDAnimationTypeFlat, // default animation type, custom flat animation (indefinite animated ring)
SVProgressHUDAnimationTypeNative // iOS native UIActivityIndicatorView
};
@interface SVProgressHUD : UIView
#pragma mark - Customization
@property (assign, nonatomic) SVProgressHUDStyle defaultStyle UI_APPEARANCE_SELECTOR; // default is SVProgressHUDStyleLight
@property (assign, nonatomic) SVProgressHUDMaskType defaultMaskType UI_APPEARANCE_SELECTOR; // default is SVProgressHUDMaskTypeNone
@property (assign, nonatomic) SVProgressHUDAnimationType defaultAnimationType UI_APPEARANCE_SELECTOR; // default is SVProgressHUDAnimationTypeFlat
@property (assign, nonatomic) CGSize minimumSize UI_APPEARANCE_SELECTOR; // default is CGSizeZero, can be used to avoid resizing for a larger message
@property (assign, nonatomic) CGFloat ringThickness UI_APPEARANCE_SELECTOR; // default is 2 pt
@property (assign, nonatomic) CGFloat ringRadius UI_APPEARANCE_SELECTOR; // default is 18 pt
@property (assign, nonatomic) CGFloat ringNoTextRadius UI_APPEARANCE_SELECTOR; // default is 24 pt
@property (assign, nonatomic) CGFloat cornerRadius UI_APPEARANCE_SELECTOR; // default is 14 pt
@property (strong, nonatomic) UIFont *font UI_APPEARANCE_SELECTOR; // default is [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline]
@property (strong, nonatomic) UIColor *backgroundColor UI_APPEARANCE_SELECTOR; // default is [UIColor whiteColor]
@property (strong, nonatomic) UIColor *foregroundColor UI_APPEARANCE_SELECTOR; // default is [UIColor blackColor]
@property (strong, nonatomic) UIColor *backgroundLayerColor UI_APPEARANCE_SELECTOR; // default is [UIColor colorWithWhite:0 alpha:0.4]
@property (strong, nonatomic) UIImage *infoImage UI_APPEARANCE_SELECTOR; // default is the bundled info image provided by Freepik
@property (strong, nonatomic) UIImage *successImage UI_APPEARANCE_SELECTOR; // default is the bundled success image provided by Freepik
@property (strong, nonatomic) UIImage *errorImage UI_APPEARANCE_SELECTOR; // default is the bundled error image provided by Freepik
@property (strong, nonatomic) UIView *viewForExtension UI_APPEARANCE_SELECTOR; // default is nil, only used if #define SV_APP_EXTENSIONS is set
@property (assign, nonatomic) NSTimeInterval minimumDismissTimeInterval; // default is 5.0 seconds
@property (assign, nonatomic) UIOffset offsetFromCenter UI_APPEARANCE_SELECTOR; // default is 0, 0
@property (assign, nonatomic) NSTimeInterval fadeInAnimationDuration; // default is 0.15
@property (assign, nonatomic) NSTimeInterval fadeOutAnimationDuration; // default is 0.15
+ (void)setDefaultStyle:(SVProgressHUDStyle)style; // default is SVProgressHUDStyleLight
+ (void)setDefaultMaskType:(SVProgressHUDMaskType)maskType; // default is SVProgressHUDMaskTypeNone
+ (void)setDefaultAnimationType:(SVProgressHUDAnimationType)type; // default is SVProgressHUDAnimationTypeFlat
+ (void)setMinimumSize:(CGSize)minimumSize; // default is CGSizeZero, can be used to avoid resizing for a larger message
+ (void)setRingThickness:(CGFloat)ringThickness; // default is 2 pt
+ (void)setRingRadius:(CGFloat)radius; // default is 18 pt
+ (void)setRingNoTextRadius:(CGFloat)radius; // default is 24 pt
+ (void)setCornerRadius:(CGFloat)cornerRadius; // default is 14 pt
+ (void)setFont:(UIFont*)font; // default is [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline]
+ (void)setForegroundColor:(UIColor*)color; // default is [UIColor blackColor], only used for SVProgressHUDStyleCustom
+ (void)setBackgroundColor:(UIColor*)color; // default is [UIColor whiteColor], only used for SVProgressHUDStyleCustom
+ (void)setBackgroundLayerColor:(UIColor*)color; // default is [UIColor colorWithWhite:0 alpha:0.5], only used for SVProgressHUDMaskTypeBlack
+ (void)setInfoImage:(UIImage*)image; // default is the bundled info image provided by Freepik
+ (void)setSuccessImage:(UIImage*)image; // default is the bundled success image provided by Freepik
+ (void)setErrorImage:(UIImage*)image; // default is the bundled error image provided by Freepik
+ (void)setViewForExtension:(UIView*)view; // default is nil, only used if #define SV_APP_EXTENSIONS is set
+ (void)setMinimumDismissTimeInterval:(NSTimeInterval)interval; // default is 5.0 seconds
+ (void)setFadeInAnimationDuration:(NSTimeInterval)duration; // default is 0.15 seconds
+ (void)setFadeOutAnimationDuration:(NSTimeInterval)duration; // default is 0.15 seconds
#pragma mark - Show Methods
+ (void)show;
+ (void)showWithMaskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use show and setDefaultMaskType: instead.")));
+ (void)showWithStatus:(NSString*)status;
+ (void)showWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use showWithStatus: and setDefaultMaskType: instead.")));
+ (void)showProgress:(float)progress;
+ (void)showProgress:(float)progress maskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use showProgress: and setDefaultMaskType: instead.")));
+ (void)showProgress:(float)progress status:(NSString*)status;
+ (void)showProgress:(float)progress status:(NSString*)status maskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use showProgress:status: and setDefaultMaskType: instead.")));
+ (void)setStatus:(NSString*)status; // change the HUD loading status while it's showing
// stops the activity indicator, shows a glyph + status, and dismisses the HUD a little bit later
+ (void)showInfoWithStatus:(NSString*)status;
+ (void)showInfoWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use showInfoWithStatus: and setDefaultMaskType: instead.")));
+ (void)showSuccessWithStatus:(NSString*)status;
+ (void)showSuccessWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use showSuccessWithStatus: and setDefaultMaskType: instead.")));
+ (void)showErrorWithStatus:(NSString*)status;
+ (void)showErrorWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use showErrorWithStatus: and setDefaultMaskType: instead.")));
// shows a image + status, use 28x28 white PNGs
+ (void)showImage:(UIImage*)image status:(NSString*)status;
+ (void)showImage:(UIImage*)image status:(NSString*)status maskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use showImage:status: and setDefaultMaskType: instead.")));
+ (void)setOffsetFromCenter:(UIOffset)offset;
+ (void)resetOffsetFromCenter;
+ (void)popActivity; // decrease activity count, if activity count == 0 the HUD is dismissed
+ (void)dismiss;
+ (void)dismissWithDelay:(NSTimeInterval)delay;
+ (BOOL)isVisible;
+ (NSTimeInterval)displayDurationForString:(NSString*)string;
@end
//
// SVProgressHUD.h
// SVProgressHUD, https://github.com/SVProgressHUD/SVProgressHUD
//
// Copyright (c) 2011-2016 Sam Vermette and contributors. All rights reserved.
//
#if !__has_feature(objc_arc)
#error SVProgressHUD is ARC only. Either turn on ARC for the project or use -fobjc-arc flag
#endif
#import "SVProgressHUD.h"
#import "SVIndefiniteAnimatedView.h"
#import "SVProgressAnimatedView.h"
#import "SVRadialGradientLayer.h"
NSString * const SVProgressHUDDidReceiveTouchEventNotification = @"SVProgressHUDDidReceiveTouchEventNotification";
NSString * const SVProgressHUDDidTouchDownInsideNotification = @"SVProgressHUDDidTouchDownInsideNotification";
NSString * const SVProgressHUDWillDisappearNotification = @"SVProgressHUDWillDisappearNotification";
NSString * const SVProgressHUDDidDisappearNotification = @"SVProgressHUDDidDisappearNotification";
NSString * const SVProgressHUDWillAppearNotification = @"SVProgressHUDWillAppearNotification";
NSString * const SVProgressHUDDidAppearNotification = @"SVProgressHUDDidAppearNotification";
NSString * const SVProgressHUDStatusUserInfoKey = @"SVProgressHUDStatusUserInfoKey";
static const CGFloat SVProgressHUDParallaxDepthPoints = 10;
static const CGFloat SVProgressHUDUndefinedProgress = -1;
static const CGFloat SVProgressHUDDefaultAnimationDuration = 0.15;
@interface SVProgressHUD ()
@property (nonatomic, strong, readonly) NSTimer *fadeOutTimer;
@property (nonatomic, readonly, getter = isClear) BOOL clear;
@property (nonatomic, strong) UIControl *overlayView;
@property (nonatomic, strong) UIView *hudView;
@property (nonatomic, strong) UILabel *statusLabel;
@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) UIView *indefiniteAnimatedView;
@property (nonatomic, strong) SVProgressAnimatedView *ringView;
@property (nonatomic, strong) SVProgressAnimatedView *backgroundRingView;
@property (nonatomic, strong) CALayer *backgroundLayer;
@property (nonatomic, readwrite) CGFloat progress;
@property (nonatomic, readwrite) NSUInteger activityCount;
@property (nonatomic, readonly) CGFloat visibleKeyboardHeight;
- (void)updateHUDFrame;
- (void)updateMask;
- (void)updateBlurBounds;
#if TARGET_OS_IOS
- (void)updateMotionEffectForOrientation:(UIInterfaceOrientation)orientation;
#endif
- (void)updateMotionEffectForXMotionEffectType:(UIInterpolatingMotionEffectType)xMotionEffectType yMotionEffectType:(UIInterpolatingMotionEffectType)yMotionEffectType;
- (void)updateViewHierachy;
- (void)setStatus:(NSString*)status;
- (void)setFadeOutTimer:(NSTimer*)timer;
- (void)registerNotifications;
- (NSDictionary*)notificationUserInfo;
- (void)positionHUD:(NSNotification*)notification;
- (void)moveToPoint:(CGPoint)newCenter rotateAngle:(CGFloat)angle;
- (void)overlayViewDidReceiveTouchEvent:(id)sender forEvent:(UIEvent*)event;
- (void)showProgress:(float)progress status:(NSString*)status;
- (void)showImage:(UIImage*)image status:(NSString*)status duration:(NSTimeInterval)duration;
- (void)showStatus:(NSString*)status;
- (void)dismiss;
- (void)dismissWithDelay:(NSTimeInterval)delay;
- (UIView*)indefiniteAnimatedView;
- (SVProgressAnimatedView*)ringView;
- (SVProgressAnimatedView*)backgroundRingView;
- (void)cancelRingLayerAnimation;
- (void)cancelIndefiniteAnimatedViewAnimation;
- (UIColor*)foregroundColorForStyle;
- (UIColor*)backgroundColorForStyle;
- (UIImage*)image:(UIImage*)image withTintColor:(UIColor*)color;
@end
@implementation SVProgressHUD {
BOOL _isInitializing;
}
+ (SVProgressHUD*)sharedView {
static dispatch_once_t once;
static SVProgressHUD *sharedView;
#if !defined(SV_APP_EXTENSIONS)
dispatch_once(&once, ^{ sharedView = [[self alloc] initWithFrame:[[[UIApplication sharedApplication] delegate] window].bounds]; });
#else
dispatch_once(&once, ^{ sharedView = [[self alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; });
#endif
return sharedView;
}
#pragma mark - Setters
+ (void)setStatus:(NSString*)status {
[[self sharedView] setStatus:status];
}
+ (void)setDefaultStyle:(SVProgressHUDStyle)style {
[self sharedView].defaultStyle = style;
}
+ (void)setDefaultMaskType:(SVProgressHUDMaskType)maskType {
[self sharedView].defaultMaskType = maskType;
}
+ (void)setDefaultAnimationType:(SVProgressHUDAnimationType)type {
[self sharedView].defaultAnimationType = type;
}
+ (void)setMinimumSize:(CGSize)minimumSize {
[self sharedView].minimumSize = minimumSize;
}
+ (void)setRingThickness:(CGFloat)ringThickness {
[self sharedView].ringThickness = ringThickness;
}
+ (void)setRingRadius:(CGFloat)radius {
[self sharedView].ringRadius = radius;
}
+ (void)setRingNoTextRadius:(CGFloat)radius {
[self sharedView].ringNoTextRadius = radius;
}
+ (void)setCornerRadius:(CGFloat)cornerRadius {
[self sharedView].cornerRadius = cornerRadius;
}
+ (void)setFont:(UIFont*)font {
[self sharedView].font = font;
}
+ (void)setForegroundColor:(UIColor*)color {
[self sharedView].foregroundColor = color;
}
+ (void)setBackgroundColor:(UIColor*)color {
[self sharedView].backgroundColor = color;
}
+ (void)setBackgroundLayerColor:(UIColor*)color {
[self sharedView].backgroundLayerColor = color;
}
+ (void)setInfoImage:(UIImage*)image {
[self sharedView].infoImage = image;
}
+ (void)setSuccessImage:(UIImage*)image {
[self sharedView].successImage = image;
}
+ (void)setErrorImage:(UIImage*)image {
[self sharedView].errorImage = image;
}
+ (void)setViewForExtension:(UIView*)view {
[self sharedView].viewForExtension = view;
}
+ (void)setMinimumDismissTimeInterval:(NSTimeInterval)interval {
[self sharedView].minimumDismissTimeInterval = interval;
}
+ (void)setFadeInAnimationDuration:(NSTimeInterval)duration {
[self sharedView].fadeInAnimationDuration = duration;
}
+ (void)setFadeOutAnimationDuration:(NSTimeInterval)duration {
[self sharedView].fadeOutAnimationDuration = duration;
}
#pragma mark - Show Methods
+ (void)show {
[self showWithStatus:nil];
}
+ (void)showWithMaskType:(SVProgressHUDMaskType)maskType {
SVProgressHUDMaskType existingMaskType = [self sharedView].defaultMaskType;
[self setDefaultMaskType:maskType];
[self show];
[self setDefaultMaskType:existingMaskType];
}
+ (void)showWithStatus:(NSString*)status {
[self sharedView];
[self showProgress:SVProgressHUDUndefinedProgress status:status];
}
+ (void)showWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType {
SVProgressHUDMaskType existingMaskType = [self sharedView].defaultMaskType;
[self setDefaultMaskType:maskType];
[self showWithStatus:status];
[self setDefaultMaskType:existingMaskType];
}
+ (void)showProgress:(float)progress {
[self showProgress:progress status:nil];
}
+ (void)showProgress:(float)progress maskType:(SVProgressHUDMaskType)maskType {
SVProgressHUDMaskType existingMaskType = [self sharedView].defaultMaskType;
[self setDefaultMaskType:maskType];
[self showProgress:progress];
[self setDefaultMaskType:existingMaskType];
}
+ (void)showProgress:(float)progress status:(NSString*)status {
[[self sharedView] showProgress:progress status:status];
}
+ (void)showProgress:(float)progress status:(NSString*)status maskType:(SVProgressHUDMaskType)maskType {
SVProgressHUDMaskType existingMaskType = [self sharedView].defaultMaskType;
[self setDefaultMaskType:maskType];
[self showProgress:progress status:status];
[self setDefaultMaskType:existingMaskType];
}
#pragma mark - Show, then automatically dismiss methods
+ (void)showInfoWithStatus:(NSString*)status {
[self showImage:[self sharedView].infoImage status:status];
}
+ (void)showInfoWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType {
SVProgressHUDMaskType existingMaskType = [self sharedView].defaultMaskType;
[self setDefaultMaskType:maskType];
[self showInfoWithStatus:status];
[self setDefaultMaskType:existingMaskType];
}
+ (void)showSuccessWithStatus:(NSString*)status {
[self showImage:[self sharedView].successImage status:status];
}
+ (void)showSuccessWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType {
SVProgressHUDMaskType existingMaskType = [self sharedView].defaultMaskType;
[self setDefaultMaskType:maskType];
[self showSuccessWithStatus:status];
[self setDefaultMaskType:existingMaskType];
}
+ (void)showErrorWithStatus:(NSString*)status {
[self showImage:[self sharedView].errorImage status:status];
}
+ (void)showErrorWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType {
SVProgressHUDMaskType existingMaskType = [self sharedView].defaultMaskType;
[self setDefaultMaskType:maskType];
[self showErrorWithStatus:status];
[self setDefaultMaskType:existingMaskType];
}
+ (void)showImage:(UIImage*)image status:(NSString*)status {
NSTimeInterval displayInterval = [self displayDurationForString:status];
[[self sharedView] showImage:image status:status duration:displayInterval];
}
+ (void)showImage:(UIImage*)image status:(NSString*)status maskType:(SVProgressHUDMaskType)maskType {
SVProgressHUDMaskType existingMaskType = [self sharedView].defaultMaskType;
[self setDefaultMaskType:maskType];
[self showImage:image status:status];
[self setDefaultMaskType:existingMaskType];
}
#pragma mark - Dismiss Methods
+ (void)popActivity {
if([self sharedView].activityCount > 0) {
[self sharedView].activityCount--;
}
if([self sharedView].activityCount == 0) {
[[self sharedView] dismiss];
}
}
+ (void)dismiss {
[self dismissWithDelay:0.0];
}
+ (void)dismissWithDelay:(NSTimeInterval)delay {
[[self sharedView] dismissWithDelay:delay];
}
#pragma mark - Offset
+ (void)setOffsetFromCenter:(UIOffset)offset {
[self sharedView].offsetFromCenter = offset;
}
+ (void)resetOffsetFromCenter {
[self setOffsetFromCenter:UIOffsetZero];
}
#pragma mark - Instance Methods
- (instancetype)initWithFrame:(CGRect)frame {
if((self = [super initWithFrame:frame])) {
_isInitializing = YES;
self.userInteractionEnabled = NO;
_backgroundColor = [UIColor clearColor];
_foregroundColor = [UIColor blackColor];
_backgroundLayerColor = [UIColor colorWithWhite:0 alpha:0.4];
self.alpha = 0.0f;
self.activityCount = 0;
// Set default values
_defaultMaskType = SVProgressHUDMaskTypeNone;
_defaultStyle = SVProgressHUDStyleLight;
_defaultAnimationType = SVProgressHUDAnimationTypeFlat;
if ([UIFont respondsToSelector:@selector(preferredFontForTextStyle:)]) {
_font = [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline];
} else {
_font = [UIFont systemFontOfSize:14.0f];
}
NSBundle *bundle = [NSBundle bundleForClass:[SVProgressHUD class]];
NSURL *url = [bundle URLForResource:@"SVProgressHUD" withExtension:@"bundle"];
NSBundle *imageBundle = [NSBundle bundleWithURL:url];
UIImage* infoImage = [UIImage imageWithContentsOfFile:[imageBundle pathForResource:@"info" ofType:@"png"]];
UIImage* successImage = [UIImage imageWithContentsOfFile:[imageBundle pathForResource:@"success" ofType:@"png"]];
UIImage* errorImage = [UIImage imageWithContentsOfFile:[imageBundle pathForResource:@"error" ofType:@"png"]];
if ([[UIImage class] instancesRespondToSelector:@selector(imageWithRenderingMode:)]) {
_infoImage = [infoImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
_successImage = [successImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
_errorImage = [errorImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
} else {
_infoImage = infoImage;
_successImage = successImage;
_errorImage = errorImage;
}
_ringThickness = 2.0f;
_ringRadius = 18.0f;
_ringNoTextRadius = 24.0f;
_cornerRadius = 14.0f;
_minimumDismissTimeInterval = 2.0;
_fadeInAnimationDuration = SVProgressHUDDefaultAnimationDuration;
_fadeOutAnimationDuration = SVProgressHUDDefaultAnimationDuration;
// Accessibility support
self.accessibilityIdentifier = @"SVProgressHUD";
self.accessibilityLabel = @"SVProgressHUD";
self.isAccessibilityElement = YES;
_isInitializing = NO;
}
return self;
}
- (void)updateHUDFrame {
// For the beginning use default values, these
// might get update if string is too large etc.
CGFloat hudWidth = 100.0f;
CGFloat hudHeight = 100.0f;
CGFloat stringHeightBuffer = 20.0f;
CGFloat stringAndContentHeightBuffer = 80.0f;
CGRect labelRect = CGRectZero;
// Check if an image or progress ring is displayed
BOOL imageUsed = (self.imageView.image) && !(self.imageView.hidden);
BOOL progressUsed = self.imageView.hidden;
// Calculate size of string and update HUD size
NSString *string = self.statusLabel.text;
if(string) {
CGSize constraintSize = CGSizeMake(200.0f, 300.0f);
CGRect stringRect;
if([string respondsToSelector:@selector(boundingRectWithSize:options:attributes:context:)]) {
stringRect = [string boundingRectWithSize:constraintSize
options:(NSStringDrawingOptions)(NSStringDrawingUsesFontLeading|NSStringDrawingTruncatesLastVisibleLine|NSStringDrawingUsesLineFragmentOrigin)
attributes:@{NSFontAttributeName: self.statusLabel.font}
context:NULL];
} else {
CGSize stringSize;
if([string respondsToSelector:@selector(sizeWithAttributes:)]) {
stringSize = [string sizeWithAttributes:@{NSFontAttributeName:[UIFont fontWithName:self.statusLabel.font.fontName size:self.statusLabel.font.pointSize]}];
} else {
#if TARGET_OS_IOS
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated"
stringSize = [string sizeWithFont:self.statusLabel.font constrainedToSize:CGSizeMake(200.0f, 300.0f)];
#pragma clang diagnostic pop
#endif
}
stringRect = CGRectMake(0.0f, 0.0f, stringSize.width, stringSize.height);
}
CGFloat stringWidth = stringRect.size.width;
CGFloat stringHeight = ceilf(CGRectGetHeight(stringRect));
if(imageUsed || progressUsed) {
hudHeight = stringAndContentHeightBuffer + stringHeight;
} else {
hudHeight = stringHeightBuffer + stringHeight;
}
if(stringWidth > hudWidth) {
hudWidth = ceilf(stringWidth/2)*2;
}
CGFloat labelRectY = (imageUsed || progressUsed) ? 68.0f : 9.0f;
if(hudHeight > 100.0f) {
labelRect = CGRectMake(12.0f, labelRectY, hudWidth, stringHeight);
hudWidth += 24.0f;
} else {
hudWidth += 24.0f;
labelRect = CGRectMake(0.0f, labelRectY, hudWidth, stringHeight);
}
}
// Update values on subviews
self.hudView.bounds = CGRectMake(0.0f, 0.0f, MAX(self.minimumSize.width, hudWidth), MAX(self.minimumSize.height, hudHeight));
labelRect.size.width += MAX(0, self.minimumSize.width - hudWidth);
[self updateBlurBounds];
if(string) {
self.imageView.center = CGPointMake(CGRectGetWidth(self.hudView.bounds)/2, 36.0f);
} else {
self.imageView.center = CGPointMake(CGRectGetWidth(self.hudView.bounds)/2, CGRectGetHeight(self.hudView.bounds)/2);
}
self.statusLabel.hidden = NO;
self.statusLabel.frame = labelRect;
// Animate value update
[CATransaction begin];
[CATransaction setDisableActions:YES];
if(string) {
if(self.defaultAnimationType == SVProgressHUDAnimationTypeFlat) {
SVIndefiniteAnimatedView *indefiniteAnimationView = (SVIndefiniteAnimatedView*)self.indefiniteAnimatedView;
indefiniteAnimationView.radius = self.ringRadius;
[indefiniteAnimationView sizeToFit];
}
CGPoint center = CGPointMake((CGRectGetWidth(self.hudView.bounds)/2), 36.0f);
self.indefiniteAnimatedView.center = center;
if(self.progress != SVProgressHUDUndefinedProgress) {
self.backgroundRingView.center = self.ringView.center = CGPointMake((CGRectGetWidth(self.hudView.bounds)/2), 36.0f);
}
} else {
if(self.defaultAnimationType == SVProgressHUDAnimationTypeFlat) {
SVIndefiniteAnimatedView *indefiniteAnimationView = (SVIndefiniteAnimatedView*)self.indefiniteAnimatedView;
indefiniteAnimationView.radius = self.ringNoTextRadius;
[indefiniteAnimationView sizeToFit];
}
CGPoint center = CGPointMake((CGRectGetWidth(self.hudView.bounds)/2), CGRectGetHeight(self.hudView.bounds)/2);
self.indefiniteAnimatedView.center = center;
if(self.progress != SVProgressHUDUndefinedProgress) {
self.backgroundRingView.center = self.ringView.center = CGPointMake((CGRectGetWidth(self.hudView.bounds)/2), CGRectGetHeight(self.hudView.bounds)/2);
}
}
[CATransaction commit];
}
- (void)updateMask {
if(self.backgroundLayer) {
[self.backgroundLayer removeFromSuperlayer];
self.backgroundLayer = nil;
}
switch (self.defaultMaskType) {
case SVProgressHUDMaskTypeCustom:
case SVProgressHUDMaskTypeBlack:{
self.backgroundLayer = [CALayer layer];
self.backgroundLayer.frame = self.bounds;
self.backgroundLayer.backgroundColor = self.defaultMaskType == SVProgressHUDMaskTypeCustom ? self.backgroundLayerColor.CGColor : [UIColor colorWithWhite:0 alpha:0.4].CGColor;
[self.backgroundLayer setNeedsDisplay];
[self.layer insertSublayer:self.backgroundLayer atIndex:0];
break;
}
case SVProgressHUDMaskTypeGradient:{
SVRadialGradientLayer *layer = [SVRadialGradientLayer layer];
self.backgroundLayer = layer;
self.backgroundLayer.frame = self.bounds;
CGPoint gradientCenter = self.center;
gradientCenter.y = (self.bounds.size.height - self.visibleKeyboardHeight)/2;
layer.gradientCenter = gradientCenter;
[self.backgroundLayer setNeedsDisplay];
[self.layer insertSublayer:self.backgroundLayer atIndex:0];
break;
}
default:
break;
}
}
- (void)updateBlurBounds {
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
if(NSClassFromString(@"UIBlurEffect") && self.defaultStyle != SVProgressHUDStyleCustom) {
// Remove background color, else the effect would not work
self.hudView.backgroundColor = [UIColor clearColor];
// Remove any old instances of UIVisualEffectViews
for (UIView *subview in self.hudView.subviews) {
if([subview isKindOfClass:[UIVisualEffectView class]]) {
[subview removeFromSuperview];
}
}
if(self.backgroundColor != [UIColor clearColor]) {
// Create blur effect
UIBlurEffectStyle blurEffectStyle = self.defaultStyle == SVProgressHUDStyleDark ? UIBlurEffectStyleDark : UIBlurEffectStyleLight;
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:blurEffectStyle];
UIVisualEffectView *blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
blurEffectView.autoresizingMask = self.hudView.autoresizingMask;
blurEffectView.frame = self.hudView.bounds;
// Add vibrancy to the blur effect to make it more vivid
UIVibrancyEffect *vibrancyEffect = [UIVibrancyEffect effectForBlurEffect:blurEffect];
UIVisualEffectView *vibrancyEffectView = [[UIVisualEffectView alloc] initWithEffect:vibrancyEffect];
vibrancyEffectView.autoresizingMask = blurEffectView.autoresizingMask;
vibrancyEffectView.bounds = blurEffectView.bounds;
[blurEffectView.contentView addSubview:vibrancyEffectView];
[self.hudView insertSubview:blurEffectView atIndex:0];
}
}
#endif
}
#if TARGET_OS_IOS
- (void)updateMotionEffectForOrientation:(UIInterfaceOrientation)orientation {
UIInterpolatingMotionEffectType xMotionEffectType = UIInterfaceOrientationIsPortrait(orientation) ? UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis : UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis;
UIInterpolatingMotionEffectType yMotionEffectType = UIInterfaceOrientationIsPortrait(orientation) ? UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis : UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis;
[self updateMotionEffectForXMotionEffectType:xMotionEffectType yMotionEffectType:yMotionEffectType];
}
#endif
- (void)updateMotionEffectForXMotionEffectType:(UIInterpolatingMotionEffectType)xMotionEffectType yMotionEffectType:(UIInterpolatingMotionEffectType)yMotionEffectType {
if([self.hudView respondsToSelector:@selector(addMotionEffect:)]) {
UIInterpolatingMotionEffect *effectX = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.x" type:xMotionEffectType];
effectX.minimumRelativeValue = @(-SVProgressHUDParallaxDepthPoints);
effectX.maximumRelativeValue = @(SVProgressHUDParallaxDepthPoints);
UIInterpolatingMotionEffect *effectY = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.y" type:yMotionEffectType];
effectY.minimumRelativeValue = @(-SVProgressHUDParallaxDepthPoints);
effectY.maximumRelativeValue = @(SVProgressHUDParallaxDepthPoints);
UIMotionEffectGroup *effectGroup = [[UIMotionEffectGroup alloc] init];
effectGroup.motionEffects = @[effectX, effectY];
// Clear old motion effect, then add new motion effects
self.hudView.motionEffects = @[];
[self.hudView addMotionEffect:effectGroup];
}
}
- (void)updateViewHierachy {
// Add the overlay (e.g. black, gradient) to the application window if necessary
if(!self.overlayView.superview) {
#if !defined(SV_APP_EXTENSIONS)
// Default case: iterate over UIApplication windows
NSEnumerator *frontToBackWindows = [UIApplication.sharedApplication.windows reverseObjectEnumerator];
for (UIWindow *window in frontToBackWindows) {
BOOL windowOnMainScreen = window.screen == UIScreen.mainScreen;
BOOL windowIsVisible = !window.hidden && window.alpha > 0;
BOOL windowLevelNormal = window.windowLevel == UIWindowLevelNormal;
if(windowOnMainScreen && windowIsVisible && windowLevelNormal) {
[window addSubview:self.overlayView];
break;
}
}
#else
// If SVProgressHUD ist used inside an app extension add it to the given view
if(self.viewForExtension) {
[self.viewForExtension addSubview:self.overlayView];
}
#endif
} else {
// The HUD is already on screen, but maybot not in front. Therefore
// ensure that overlay will be on top of rootViewController (which may
// be changed during runtime).
[self.overlayView.superview bringSubviewToFront:self.overlayView];
}
// Add self to the overlay view
if(!self.superview){
[self.overlayView addSubview:self];
}
if(!self.hudView.superview) {
[self addSubview:self.hudView];
}
}
- (void)setStatus:(NSString*)status {
self.statusLabel.text = status;
[self updateHUDFrame];
}
- (void)setFadeOutTimer:(NSTimer*)timer {
if(_fadeOutTimer) {
[_fadeOutTimer invalidate], _fadeOutTimer = nil;
}
if(timer) {
_fadeOutTimer = timer;
}
}
#pragma mark - Notifications and their handling
- (void)registerNotifications {
#if TARGET_OS_IOS
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(positionHUD:)
name:UIApplicationDidChangeStatusBarOrientationNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(positionHUD:)
name:UIKeyboardWillHideNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(positionHUD:)
name:UIKeyboardDidHideNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(positionHUD:)
name:UIKeyboardWillShowNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(positionHUD:)
name:UIKeyboardDidShowNotification
object:nil];
#endif
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(positionHUD:)
name:UIApplicationDidBecomeActiveNotification
object:nil];
}
- (NSDictionary*)notificationUserInfo{
return (self.statusLabel.text ? @{SVProgressHUDStatusUserInfoKey : self.statusLabel.text} : nil);
}
- (void)positionHUD:(NSNotification*)notification {
CGFloat keyboardHeight = 0.0f;
double animationDuration = 0.0;
#if !defined(SV_APP_EXTENSIONS) && TARGET_OS_IOS
self.frame = [[[UIApplication sharedApplication] delegate] window].bounds;
UIInterfaceOrientation orientation = UIApplication.sharedApplication.statusBarOrientation;
#elif !defined(SV_APP_EXTENSIONS)
self.frame = [UIApplication sharedApplication].keyWindow.bounds;
#else
if (self.viewForExtension) {
self.frame = self.viewForExtension.frame;
} else {
self.frame = UIScreen.mainScreen.bounds;
}
UIInterfaceOrientation orientation = CGRectGetWidth(self.frame) > CGRectGetHeight(self.frame) ? UIInterfaceOrientationLandscapeLeft : UIInterfaceOrientationPortrait;
#endif
// no transforms applied to window in iOS 8, but only if compiled with iOS 8 sdk as base sdk, otherwise system supports old rotation logic.
BOOL ignoreOrientation = NO;
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
if([[NSProcessInfo processInfo] respondsToSelector:@selector(operatingSystemVersion)]) {
ignoreOrientation = YES;
}
#endif
#if TARGET_OS_IOS
// Get keyboardHeight in regards to current state
if(notification) {
NSDictionary* keyboardInfo = [notification userInfo];
CGRect keyboardFrame = [keyboardInfo[UIKeyboardFrameBeginUserInfoKey] CGRectValue];
animationDuration = [keyboardInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];
if(notification.name == UIKeyboardWillShowNotification || notification.name == UIKeyboardDidShowNotification) {
keyboardHeight = CGRectGetWidth(keyboardFrame);
if(ignoreOrientation || UIInterfaceOrientationIsPortrait(orientation)) {
keyboardHeight = CGRectGetHeight(keyboardFrame);
}
}
} else {
keyboardHeight = self.visibleKeyboardHeight;
}
#endif
// Get the currently active frame of the display (depends on orientation)
CGRect orientationFrame = self.bounds;
#if !defined(SV_APP_EXTENSIONS) && TARGET_OS_IOS
CGRect statusBarFrame = UIApplication.sharedApplication.statusBarFrame;
#else
CGRect statusBarFrame = CGRectZero;
#endif
#if TARGET_OS_IOS
if(!ignoreOrientation && UIInterfaceOrientationIsLandscape(orientation)) {
float temp = CGRectGetWidth(orientationFrame);
orientationFrame.size.width = CGRectGetHeight(orientationFrame);
orientationFrame.size.height = temp;
temp = CGRectGetWidth(statusBarFrame);
statusBarFrame.size.width = CGRectGetHeight(statusBarFrame);
statusBarFrame.size.height = temp;
}
// Update the motion effects in regards to orientation
[self updateMotionEffectForOrientation:orientation];
#else
[self updateMotionEffectForXMotionEffectType:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis yMotionEffectType:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];
#endif
// Calculate available height for display
CGFloat activeHeight = CGRectGetHeight(orientationFrame);
if(keyboardHeight > 0) {
activeHeight += CGRectGetHeight(statusBarFrame)*2;
}
activeHeight -= keyboardHeight;
CGFloat posX = CGRectGetWidth(orientationFrame)/2.0f;
CGFloat posY = floorf(activeHeight*0.45f);
CGFloat rotateAngle = 0.0;
CGPoint newCenter = CGPointMake(posX, posY);
// Update posX and posY in regards to orientation
#if TARGET_OS_IOS
if(!ignoreOrientation) {
switch (orientation) {
case UIInterfaceOrientationPortraitUpsideDown:
rotateAngle = (CGFloat) M_PI;
newCenter = CGPointMake(posX, CGRectGetHeight(orientationFrame)-posY);
break;
case UIInterfaceOrientationLandscapeLeft:
rotateAngle = (CGFloat) (-M_PI/2.0f);
newCenter = CGPointMake(posY, posX);
break;
case UIInterfaceOrientationLandscapeRight:
rotateAngle = (CGFloat) (M_PI/2.0f);
newCenter = CGPointMake(CGRectGetHeight(orientationFrame)-posY, posX);
break;
default: // Same as UIInterfaceOrientationPortrait
rotateAngle = 0.0f;
newCenter = CGPointMake(posX, posY);
break;
}
}
#endif
if(notification) {
// Animate update if notification was present
__weak SVProgressHUD *weakSelf = self;
[UIView animateWithDuration:animationDuration
delay:0
options:UIViewAnimationOptionAllowUserInteraction
animations:^{
__strong SVProgressHUD *strongSelf = weakSelf;
if(strongSelf) {
[strongSelf moveToPoint:newCenter rotateAngle:rotateAngle];
[strongSelf.hudView setNeedsDisplay];
}
} completion:NULL];
} else {
[self moveToPoint:newCenter rotateAngle:rotateAngle];
[self.hudView setNeedsDisplay];
}
[self updateMask];
}
- (void)moveToPoint:(CGPoint)newCenter rotateAngle:(CGFloat)angle {
self.hudView.transform = CGAffineTransformMakeRotation(angle);
self.hudView.center = CGPointMake(newCenter.x + self.offsetFromCenter.horizontal, newCenter.y + self.offsetFromCenter.vertical);
}
#pragma mark - Event handling
- (void)overlayViewDidReceiveTouchEvent:(id)sender forEvent:(UIEvent*)event {
[[NSNotificationCenter defaultCenter] postNotificationName:SVProgressHUDDidReceiveTouchEventNotification
object:self
userInfo:[self notificationUserInfo]];
UITouch *touch = event.allTouches.anyObject;
CGPoint touchLocation = [touch locationInView:self];
if(CGRectContainsPoint(self.hudView.frame, touchLocation)) {
[[NSNotificationCenter defaultCenter] postNotificationName:SVProgressHUDDidTouchDownInsideNotification
object:self
userInfo:[self notificationUserInfo]];
}
}
#pragma mark - Master show/dismiss methods
- (void)showProgress:(float)progress status:(NSString*)status {
__weak SVProgressHUD *weakSelf = self;
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
__strong SVProgressHUD *strongSelf = weakSelf;
if(strongSelf){
// Update / Check view hierachy to ensure the HUD is visible
[strongSelf updateViewHierachy];
// Reset imageView and fadeout timer if an image is currently displayed
strongSelf.imageView.hidden = YES;
strongSelf.imageView.image = nil;
if(strongSelf.fadeOutTimer) {
strongSelf.activityCount = 0;
}
strongSelf.fadeOutTimer = nil;
// Update text and set progress to the given value
strongSelf.statusLabel.text = status;
strongSelf.progress = progress;
// Choose the "right" indicator depending on the progress
if(progress >= 0) {
// Cancel the indefiniteAnimatedView, then show the ringLayer
[strongSelf cancelIndefiniteAnimatedViewAnimation];
// Add ring to HUD and set progress
[strongSelf.hudView addSubview:strongSelf.ringView];
[strongSelf.hudView addSubview:strongSelf.backgroundRingView];
strongSelf.ringView.strokeEnd = progress;
// Updat the activity count
if(progress == 0) {
strongSelf.activityCount++;
}
} else {
// Cancel the ringLayer animation, then show the indefiniteAnimatedView
[strongSelf cancelRingLayerAnimation];
// Add indefiniteAnimatedView to HUD
[strongSelf.hudView addSubview:strongSelf.indefiniteAnimatedView];
if([strongSelf.indefiniteAnimatedView respondsToSelector:@selector(startAnimating)]) {
[(id)strongSelf.indefiniteAnimatedView startAnimating];
}
// Update the activity count
strongSelf.activityCount++;
}
// Show
[strongSelf showStatus:status];
}
}];
}
- (void)showImage:(UIImage*)image status:(NSString*)status duration:(NSTimeInterval)duration {
__weak SVProgressHUD *weakSelf = self;
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
__strong SVProgressHUD *strongSelf = weakSelf;
if(strongSelf){
// Update / Check view hierachy to ensure the HUD is visible
[strongSelf updateViewHierachy];
// Reset progress and cancel any running animation
strongSelf.progress = SVProgressHUDUndefinedProgress;
[strongSelf cancelRingLayerAnimation];
[strongSelf cancelIndefiniteAnimatedViewAnimation];
// Update imageView
UIColor *tintColor = strongSelf.foregroundColorForStyle;
UIImage *tintedImage = image;
if([strongSelf.imageView respondsToSelector:@selector(setTintColor:)]) {
if (tintedImage.renderingMode != UIImageRenderingModeAlwaysTemplate) {
tintedImage = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
}
strongSelf.imageView.tintColor = tintColor;
} else {
tintedImage = [strongSelf image:image withTintColor:tintColor];
}
strongSelf.imageView.image = tintedImage;
strongSelf.imageView.hidden = NO;
// Update text
strongSelf.statusLabel.text = status;
// Show
[strongSelf showStatus:status];
// An image will dismissed automatically. Therefore we start a timer
// which then will call dismiss after the predefined duration
strongSelf.fadeOutTimer = [NSTimer timerWithTimeInterval:duration target:strongSelf selector:@selector(dismiss) userInfo:nil repeats:NO];
[[NSRunLoop mainRunLoop] addTimer:strongSelf.fadeOutTimer forMode:NSRunLoopCommonModes];
}
}];
}
- (void)showStatus:(NSString*)status {
// Update the HUDs frame to the new content and position HUD
[self updateHUDFrame];
[self positionHUD:nil];
// Update accesibilty as well as user interaction
if(self.defaultMaskType != SVProgressHUDMaskTypeNone) {
self.overlayView.userInteractionEnabled = YES;
self.accessibilityLabel = status;
self.isAccessibilityElement = YES;
} else {
self.overlayView.userInteractionEnabled = NO;
self.hudView.accessibilityLabel = status;
self.hudView.isAccessibilityElement = YES;
}
// Show overlay
self.overlayView.backgroundColor = [UIColor clearColor];
// Show if not already visible (depending on alpha)
if(self.alpha != 1.0f || self.hudView.alpha != 1.0f) {
// Post notification to inform user
[[NSNotificationCenter defaultCenter] postNotificationName:SVProgressHUDWillAppearNotification
object:self
userInfo:[self notificationUserInfo]];
// Zoom HUD a little to make a nice appear / pop up animation
self.hudView.transform = CGAffineTransformScale(self.hudView.transform, 1.3, 1.3);
// Set initial values to handle iOS 7 (and above) UIToolbar which not answers well to hierarchy opacity change
self.alpha = 0.0f;
self.hudView.alpha = 0.0f;
// Define blocks
__weak SVProgressHUD *weakSelf = self;
__block void (^animationsBlock)(void) = ^{
__strong SVProgressHUD *strongSelf = weakSelf;
if(strongSelf) {
// Shrink HUD to finish pop up animation
strongSelf.hudView.transform = CGAffineTransformScale(strongSelf.hudView.transform, 1/1.3f, 1/1.3f);
strongSelf.alpha = 1.0f;
strongSelf.hudView.alpha = 1.0f;
}
};
__block void (^completionBlock)(void) = ^{
__strong SVProgressHUD *strongSelf = weakSelf;
if(strongSelf) {
/// Register observer <=> we now have to handle orientation changes etc.
[strongSelf registerNotifications];
// Post notification to inform user
[[NSNotificationCenter defaultCenter] postNotificationName:SVProgressHUDDidAppearNotification
object:strongSelf
userInfo:[strongSelf notificationUserInfo]];
}
// Update accesibilty
UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil);
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, status);
};
if (self.fadeInAnimationDuration > 0) {
// Animate appearance
[UIView animateWithDuration:self.fadeInAnimationDuration
delay:0
options:(UIViewAnimationOptions) (UIViewAnimationOptionAllowUserInteraction | UIViewAnimationCurveEaseOut | UIViewAnimationOptionBeginFromCurrentState)
animations:^{
animationsBlock();
} completion:^(BOOL finished) {
completionBlock();
}];
} else {
animationsBlock();
completionBlock();
}
// Inform iOS to redraw the view hierachy
[self setNeedsDisplay];
}
}
- (void)dismiss {
[self dismissWithDelay:0];
}
- (void)dismissWithDelay:(NSTimeInterval)delay {
__weak SVProgressHUD *weakSelf = self;
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
__strong SVProgressHUD *strongSelf = weakSelf;
if(strongSelf){
// Dismiss if visible (depending on alpha)
if(strongSelf.alpha != 0.0f || strongSelf.hudView.alpha != 0.0f){
// Post notification to inform user
[[NSNotificationCenter defaultCenter] postNotificationName:SVProgressHUDWillDisappearNotification
object:nil
userInfo:[strongSelf notificationUserInfo]];
// Reset activitiy count
strongSelf.activityCount = 0;
// Define blocks
__block void (^animationsBlock)(void) = ^{
strongSelf.hudView.transform = CGAffineTransformScale(strongSelf.hudView.transform, 0.8f, 0.8f);
strongSelf.alpha = 0.0f;
strongSelf.hudView.alpha = 0.0f;
};
__block void (^completionBlock)(void) = ^{
// Clean up view hierachy (overlays)
[strongSelf.overlayView removeFromSuperview];
[strongSelf.hudView removeFromSuperview];
[strongSelf removeFromSuperview];
// Reset progress and cancel any running animation
strongSelf.progress = SVProgressHUDUndefinedProgress;
[strongSelf cancelRingLayerAnimation];
[strongSelf cancelIndefiniteAnimatedViewAnimation];
// Remove observer <=> we do not have to handle orientation changes etc.
[[NSNotificationCenter defaultCenter] removeObserver:strongSelf];
// Post notification to inform user
[[NSNotificationCenter defaultCenter] postNotificationName:SVProgressHUDDidDisappearNotification
object:strongSelf
userInfo:[strongSelf notificationUserInfo]];
// Tell the rootViewController to update the StatusBar appearance
#if !defined(SV_APP_EXTENSIONS) && TARGET_OS_IOS
UIViewController *rootController = [[UIApplication sharedApplication] keyWindow].rootViewController;
if([rootController respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
[rootController setNeedsStatusBarAppearanceUpdate];
}
#endif
// Update accesibilty
UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil);
};
if (strongSelf.fadeOutAnimationDuration > 0) {
// Animate appearance
[UIView animateWithDuration:strongSelf.fadeOutAnimationDuration
delay:delay
options:(UIViewAnimationOptions) (UIViewAnimationOptionAllowUserInteraction | UIViewAnimationCurveEaseIn | UIViewAnimationOptionBeginFromCurrentState)
animations:^{
animationsBlock();
} completion:^(BOOL finished) {
completionBlock();
}];
} else {
animationsBlock();
completionBlock();
}
// Inform iOS to redraw the view hierachy
[strongSelf setNeedsDisplay];
}
}
}];
}
#pragma mark - Ring progress animation
- (UIView*)indefiniteAnimatedView {
// Get the correct spinner for defaultAnimationType
if(self.defaultAnimationType == SVProgressHUDAnimationTypeFlat){
// Check if spinner exists and is an object of different class
if(_indefiniteAnimatedView && ![_indefiniteAnimatedView isKindOfClass:[SVIndefiniteAnimatedView class]]){
[_indefiniteAnimatedView removeFromSuperview];
_indefiniteAnimatedView = nil;
}
if(!_indefiniteAnimatedView){
_indefiniteAnimatedView = [[SVIndefiniteAnimatedView alloc] initWithFrame:CGRectZero];
}
// Update styling
SVIndefiniteAnimatedView *indefiniteAnimatedView = (SVIndefiniteAnimatedView*)_indefiniteAnimatedView;
indefiniteAnimatedView.strokeColor = self.foregroundColorForStyle;
indefiniteAnimatedView.strokeThickness = self.ringThickness;
indefiniteAnimatedView.radius = self.statusLabel.text ? self.ringRadius : self.ringNoTextRadius;
} else {
// Check if spinner exists and is an object of different class
if(_indefiniteAnimatedView && ![_indefiniteAnimatedView isKindOfClass:[UIActivityIndicatorView class]]){
[_indefiniteAnimatedView removeFromSuperview];
_indefiniteAnimatedView = nil;
}
if(!_indefiniteAnimatedView){
_indefiniteAnimatedView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
}
// Update styling
UIActivityIndicatorView *activityIndicatorView = (UIActivityIndicatorView*)_indefiniteAnimatedView;
activityIndicatorView.color = self.foregroundColorForStyle;
}
[_indefiniteAnimatedView sizeToFit];
return _indefiniteAnimatedView;
}
- (SVProgressAnimatedView*)ringView {
if(!_ringView) {
_ringView = [[SVProgressAnimatedView alloc] initWithFrame:CGRectZero];
}
// Update styling
_ringView.strokeColor = self.foregroundColorForStyle;
_ringView.strokeThickness = self.ringThickness;
_ringView.radius = self.statusLabel.text ? self.ringRadius : self.ringNoTextRadius;
return _ringView;
}
- (SVProgressAnimatedView*)backgroundRingView {
if(!_backgroundRingView) {
_backgroundRingView = [[SVProgressAnimatedView alloc] initWithFrame:CGRectZero];
_backgroundRingView.strokeEnd = 1.0f;
}
// Update styling
_backgroundRingView.strokeColor = [self.foregroundColorForStyle colorWithAlphaComponent:0.1f];
_backgroundRingView.strokeThickness = self.ringThickness;
_backgroundRingView.radius = self.statusLabel.text ? self.ringRadius : self.ringNoTextRadius;
return _backgroundRingView;
}
- (void)cancelRingLayerAnimation {
// Animate value update, stop animation
[CATransaction begin];
[CATransaction setDisableActions:YES];
[self.hudView.layer removeAllAnimations];
self.ringView.strokeEnd = 0.0f;
[CATransaction commit];
// Remove from view
[self.ringView removeFromSuperview];
[self.backgroundRingView removeFromSuperview];
}
- (void)cancelIndefiniteAnimatedViewAnimation {
// Stop animation
if([self.indefiniteAnimatedView respondsToSelector:@selector(stopAnimating)]) {
[(id)self.indefiniteAnimatedView stopAnimating];
}
// Remove from view
[self.indefiniteAnimatedView removeFromSuperview];
}
#pragma mark - Utilities
+ (BOOL)isVisible {
return ([self sharedView].alpha > 0);
}
#pragma mark - Getters
+ (NSTimeInterval)displayDurationForString:(NSString*)string {
return MAX((float)string.length * 0.06 + 0.5, [self sharedView].minimumDismissTimeInterval);
}
- (UIColor*)foregroundColorForStyle {
if(self.defaultStyle == SVProgressHUDStyleLight) {
return [UIColor blackColor];
} else if(self.defaultStyle == SVProgressHUDStyleDark) {
return [UIColor whiteColor];
} else {
return self.foregroundColor;
}
}
- (UIColor*)backgroundColorForStyle {
if(self.defaultStyle == SVProgressHUDStyleLight) {
return [UIColor whiteColor];
} else if(self.defaultStyle == SVProgressHUDStyleDark) {
return [UIColor blackColor];
} else {
return self.backgroundColor;
}
}
- (UIImage*)image:(UIImage*)image withTintColor:(UIColor*)color {
CGRect rect = CGRectMake(0.0f, 0.0f, image.size.width, image.size.height);
UIGraphicsBeginImageContextWithOptions(rect.size, NO, image.scale);
CGContextRef c = UIGraphicsGetCurrentContext();
[image drawInRect:rect];
CGContextSetFillColorWithColor(c, [color CGColor]);
CGContextSetBlendMode(c, kCGBlendModeSourceAtop);
CGContextFillRect(c, rect);
UIImage *tintedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return tintedImage;
}
- (BOOL)isClear { // used for iOS 7 and above
return (self.defaultMaskType == SVProgressHUDMaskTypeClear || self.defaultMaskType == SVProgressHUDMaskTypeNone);
}
- (UIControl*)overlayView {
if(!_overlayView) {
#if !defined(SV_APP_EXTENSIONS)
CGRect windowBounds = [[[UIApplication sharedApplication] delegate] window].bounds;
_overlayView = [[UIControl alloc] initWithFrame:windowBounds];
#else
_overlayView = [[UIControl alloc] initWithFrame:[UIScreen mainScreen].bounds];
#endif
_overlayView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_overlayView.backgroundColor = [UIColor clearColor];
[_overlayView addTarget:self action:@selector(overlayViewDidReceiveTouchEvent:forEvent:) forControlEvents:UIControlEventTouchDown];
}
return _overlayView;
}
- (UIView*)hudView {
if(!_hudView) {
_hudView = [[UIView alloc] initWithFrame:CGRectZero];
_hudView.layer.masksToBounds = YES;
_hudView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin;
}
// Update styling
_hudView.layer.cornerRadius = self.cornerRadius;
_hudView.backgroundColor = self.backgroundColorForStyle;
return _hudView;
}
- (UILabel*)statusLabel {
if(!_statusLabel) {
_statusLabel = [[UILabel alloc] initWithFrame:CGRectZero];
_statusLabel.backgroundColor = [UIColor clearColor];
_statusLabel.adjustsFontSizeToFitWidth = YES;
_statusLabel.textAlignment = NSTextAlignmentCenter;
_statusLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters;
_statusLabel.numberOfLines = 0;
}
if(!_statusLabel.superview) {
[self.hudView addSubview:_statusLabel];
}
// Update styling
_statusLabel.textColor = self.foregroundColorForStyle;
_statusLabel.font = self.font;
return _statusLabel;
}
- (UIImageView*)imageView {
if(!_imageView) {
_imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 28.0f, 28.0f)];
}
if(!_imageView.superview) {
[self.hudView addSubview:_imageView];
}
return _imageView;
}
- (CGFloat)visibleKeyboardHeight {
#if !defined(SV_APP_EXTENSIONS)
UIWindow *keyboardWindow = nil;
for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) {
if(![[testWindow class] isEqual:[UIWindow class]]) {
keyboardWindow = testWindow;
break;
}
}
for (__strong UIView *possibleKeyboard in [keyboardWindow subviews]) {
if([possibleKeyboard isKindOfClass:NSClassFromString(@"UIPeripheralHostView")] || [possibleKeyboard isKindOfClass:NSClassFromString(@"UIKeyboard")]) {
return CGRectGetHeight(possibleKeyboard.bounds);
} else if([possibleKeyboard isKindOfClass:NSClassFromString(@"UIInputSetContainerView")]) {
for (__strong UIView *possibleKeyboardSubview in [possibleKeyboard subviews]) {
if([possibleKeyboardSubview isKindOfClass:NSClassFromString(@"UIInputSetHostView")]) {
return CGRectGetHeight(possibleKeyboardSubview.bounds);
}
}
}
}
#endif
return 0;
}
#pragma mark - UIAppearance Setters
- (void)setDefaultStyle:(SVProgressHUDStyle)style {
if (!_isInitializing) _defaultStyle = style;
}
- (void)setDefaultMaskType:(SVProgressHUDMaskType)maskType {
if (!_isInitializing) _defaultMaskType = maskType;
}
- (void)setDefaultAnimationType:(SVProgressHUDAnimationType)animationType {
if (!_isInitializing) _defaultAnimationType = animationType;
}
- (void)setMinimumSize:(CGSize)minimumSize {
if (!_isInitializing) _minimumSize = minimumSize;
}
- (void)setRingThickness:(CGFloat)ringThickness {
if (!_isInitializing) _ringThickness = ringThickness;
}
- (void)setRingRadius:(CGFloat)ringRadius {
if (!_isInitializing) _ringRadius = ringRadius;
}
- (void)setRingNoTextRadius:(CGFloat)ringNoTextRadius {
if (!_isInitializing) _ringNoTextRadius = ringNoTextRadius;
}
- (void)setCornerRadius:(CGFloat)cornerRadius {
if (!_isInitializing) _cornerRadius = cornerRadius;
}
- (void)setFont:(UIFont*)font {
if (!_isInitializing) _font = font;
}
- (void)setForegroundColor:(UIColor*)color {
if (!_isInitializing) _foregroundColor = color;
}
- (void)setBackgroundColor:(UIColor*)color {
if (!_isInitializing) _backgroundColor = color;
}
- (void)setBackgroundLayerColor:(UIColor*)color {
if (!_isInitializing) _backgroundLayerColor = color;
}
- (void)setInfoImage:(UIImage*)image {
if (!_isInitializing) _infoImage = image;
}
- (void)setSuccessImage:(UIImage*)image {
if (!_isInitializing) _successImage = image;
}
- (void)setErrorImage:(UIImage*)image {
if (!_isInitializing) _errorImage = image;
}
- (void)setViewForExtension:(UIView*)view {
if (!_isInitializing) _viewForExtension = view;
}
- (void)setOffsetFromCenter:(UIOffset)offset {
if (!_isInitializing) _offsetFromCenter = offset;
}
- (void)setMinimumDismissTimeInterval:(NSTimeInterval)minimumDismissTimeInterval {
if (!_isInitializing) _minimumDismissTimeInterval = minimumDismissTimeInterval;
}
- (void)setFadeInAnimationDuration:(NSTimeInterval)duration {
if (!_isInitializing) _fadeInAnimationDuration = duration;
}
- (void)setFadeOutAnimationDuration:(NSTimeInterval)duration {
if (!_isInitializing) _fadeOutAnimationDuration = duration;
}
@end
//
// SVRadialGradientLayer.h
// SVProgressHUD, https://github.com/SVProgressHUD/SVProgressHUD
//
// Copyright (c) 2014-2016 Tobias Tiemerding. All rights reserved.
//
#import <QuartzCore/QuartzCore.h>
@interface SVRadialGradientLayer : CALayer
@property (nonatomic) CGPoint gradientCenter;
@end
//
// SVRadialGradientLayer.m
// SVProgressHUD, https://github.com/SVProgressHUD/SVProgressHUD
//
// Copyright (c) 2014-2016 Tobias Tiemerding. All rights reserved.
//
#import "SVRadialGradientLayer.h"
@implementation SVRadialGradientLayer
- (void)drawInContext:(CGContextRef)context {
size_t locationsCount = 2;
CGFloat locations[2] = {0.0f, 1.0f};
CGFloat colors[8] = {0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.75f};
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGGradientRef gradient = CGGradientCreateWithColorComponents(colorSpace, colors, locations, locationsCount);
CGColorSpaceRelease(colorSpace);
float radius = MIN(self.bounds.size.width , self.bounds.size.height);
CGContextDrawRadialGradient (context, gradient, self.gradientCenter, 0, self.gradientCenter, radius, kCGGradientDrawsAfterEndLocation);
CGGradientRelease(gradient);
}
@end
...@@ -25,20 +25,7 @@ class NewCKVc: BaseViewController,UITableViewDelegate,UITableViewDataSource,CKNo ...@@ -25,20 +25,7 @@ class NewCKVc: BaseViewController,UITableViewDelegate,UITableViewDataSource,CKNo
func Print_Gprinter_View_Print(data: Array<Dictionary<String, Any>>) { func Print_Gprinter_View_Print(data: Array<Dictionary<String, Any>>) {
print("打印") print("打印")
let dele = UIApplication.shared.delegate as! AppDelegate
// let tscCmd = TscCommand()
// tscCmd.hasResponse = true
// tscCmd.addSize(50, 30)
// tscCmd.addGap(withM: 2, withN: 0)
// tscCmd.addReference(24, 24)
// tscCmd.addSpeed(4)
// tscCmd.addDensity(8)
// tscCmd.addDirection(0)
// tscCmd.addComonCommand()
// tscCmd.addCls()
// tscCmd.addQRCode(20, 4, "G", 4, "L", 0, "格利IOS蓝牙打印")
// tscCmd.addPrint(1, 1)
...@@ -154,18 +141,7 @@ class NewCKVc: BaseViewController,UITableViewDelegate,UITableViewDataSource,CKNo ...@@ -154,18 +141,7 @@ class NewCKVc: BaseViewController,UITableViewDelegate,UITableViewDataSource,CKNo
var goodsInfoArr:Array<Any> = [] var goodsInfoArr:Array<Any> = []
@IBOutlet weak var gm_view: UIView! @IBOutlet weak var gm_view: UIView!
@IBAction func ck_action(_ sender: UIButton) { @IBAction func ck_action(_ sender: UIButton) {
print("pw = ",BLKWrite.instance()?.printWidth())
let esc = EscCommand()
esc.hasResponse = true
esc.addInitializePrinter()
esc.addText("测试")
esc.addPrintMode(0x1B)
esc.addPrintAndFeedLines(8)
BLKWrite.instance()?.writeEscData(esc.getCommand(), withResponse: esc.hasResponse)
return
if isGm { if isGm {
if typeSelect == nil { if typeSelect == nil {
HUD.flash(.label("请选择出库类型"),delay: 1.2) HUD.flash(.label("请选择出库类型"),delay: 1.2)
......
//
// BtViewController.h
// GeliBusinessPlatform
//
// Created by junye lu on 2021/2/26.
// Copyright © 2021 junye lu. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface BtViewController : UIViewController
@end
NS_ASSUME_NONNULL_END
//
// BtViewController.m
// GeliBusinessPlatform
//
// Created by junye lu on 2021/2/26.
// Copyright © 2021 junye lu. All rights reserved.
//
#import "BtViewController.h"
#import "HLBLEManager.h"
#import "SVProgressHUD.h"
@interface BtViewController ()
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (strong, nonatomic)NSMutableArray *deviceArray; /**< 蓝牙设备个数 */
@property (strong, nonatomic)NSMutableArray *selectArray;//选择蓝牙
@end
@implementation BtViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
_deviceArray = [[NSMutableArray alloc] init];
_tableView.rowHeight = 44;
HLBLEManager *manager = [HLBLEManager sharedInstance];
__weak HLBLEManager *weakManager = manager;
manager.stateUpdateBlock = ^(CBCentralManager *central) {
NSString *info = nil;
switch (central.state) {
case CBCentralManagerStatePoweredOn:
info = @"蓝牙已打开,并且可用";
//三种种方式
// 方式1
[weakManager scanForPeripheralsWithServiceUUIDs:nil options:nil];
// // 方式2
// [central scanForPeripheralsWithServices:nil options:nil];
// // 方式3
// [weakManager scanForPeripheralsWithServiceUUIDs:nil options:nil didDiscoverPeripheral:^(CBCentralManager *central, CBPeripheral *peripheral, NSDictionary *advertisementData, NSNumber *RSSI) {
//
// }];
break;
case CBCentralManagerStatePoweredOff:
info = @"蓝牙可用,未打开";
break;
case CBCentralManagerStateUnsupported:
info = @"SDK不支持";
break;
case CBCentralManagerStateUnauthorized:
info = @"程序未授权";
break;
case CBCentralManagerStateResetting:
info = @"CBCentralManagerStateResetting";
break;
case CBCentralManagerStateUnknown:
info = @"CBCentralManagerStateUnknown";
break;
}
[SVProgressHUD setDefaultStyle:SVProgressHUDStyleDark];
[SVProgressHUD showInfoWithStatus:info ];
};
manager.discoverPeripheralBlcok = ^(CBCentralManager *central, CBPeripheral *peripheral, NSDictionary *advertisementData, NSNumber *RSSI) {
if (peripheral.name.length <= 0) {
return ;
}
if (self.deviceArray.count == 0) {
NSDictionary *dict = @{@"peripheral":peripheral, @"RSSI":RSSI};
[self.deviceArray addObject:dict];
} else {
BOOL isExist = NO;
for (int i = 0; i < self.deviceArray.count; i++) {
NSDictionary *dict = [self.deviceArray objectAtIndex:i];
CBPeripheral *per = dict[@"peripheral"];
if ([per.identifier.UUIDString isEqualToString:peripheral.identifier.UUIDString]) {
isExist = YES;
NSDictionary *dict = @{@"peripheral":peripheral, @"RSSI":RSSI};
[_deviceArray replaceObjectAtIndex:i withObject:dict];
}
}
if (!isExist) {
NSDictionary *dict = @{@"peripheral":peripheral, @"RSSI":RSSI};
[self.deviceArray addObject:dict];
}
}
[self.tableView reloadData];
};
}
@end
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="BtViewController">
<connections>
<outlet property="tableView" destination="1gI-Ls-VbE" id="aPw-0b-JNm"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="icy-5U-c3o">
<rect key="frame" x="0.0" y="44" width="414" height="64"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="蓝牙打印设置" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="erR-E1-CbN">
<rect key="frame" x="156" y="20" width="102" height="24"/>
<fontDescription key="fontDescription" name="PingFangSC-Medium" family="PingFang SC" pointSize="17"/>
<color key="textColor" name="标题字颜色"/>
<nil key="highlightedColor"/>
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="fanhui" translatesAutoresizingMaskIntoConstraints="NO" id="Mj8-jq-6dS">
<rect key="frame" x="12" y="23.5" width="10" height="17"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="17" id="6AQ-5J-RlT"/>
<constraint firstAttribute="width" constant="10" id="Id1-RK-FZT"/>
<constraint firstAttribute="height" constant="17" id="oCz-0v-YtM"/>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="10" id="rOS-so-0SA"/>
</constraints>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="xZc-Xt-ZU2">
<rect key="frame" x="0.0" y="0.0" width="46" height="64"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="46" id="BLS-5O-HaU"/>
<constraint firstAttribute="width" constant="46" id="hrV-57-cL5"/>
</constraints>
</button>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="erR-E1-CbN" firstAttribute="centerY" secondItem="icy-5U-c3o" secondAttribute="centerY" id="6vr-rN-nq5"/>
<constraint firstItem="Mj8-jq-6dS" firstAttribute="leading" secondItem="icy-5U-c3o" secondAttribute="leading" constant="12" id="6zG-YL-i0f"/>
<constraint firstAttribute="bottom" secondItem="xZc-Xt-ZU2" secondAttribute="bottom" id="LmN-2F-TFd"/>
<constraint firstItem="xZc-Xt-ZU2" firstAttribute="leading" secondItem="icy-5U-c3o" secondAttribute="leading" id="MeH-A1-2uy"/>
<constraint firstItem="erR-E1-CbN" firstAttribute="centerX" secondItem="icy-5U-c3o" secondAttribute="centerX" id="O2O-ff-LSm"/>
<constraint firstItem="xZc-Xt-ZU2" firstAttribute="top" secondItem="icy-5U-c3o" secondAttribute="top" id="gQv-nP-gD1"/>
<constraint firstItem="Mj8-jq-6dS" firstAttribute="centerY" secondItem="icy-5U-c3o" secondAttribute="centerY" id="lDH-8L-8ie"/>
<constraint firstAttribute="height" constant="64" id="zIa-e1-3OT"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="clr-t9-pBK">
<rect key="frame" x="0.0" y="813" width="414" height="49"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="guanbi" translatesAutoresizingMaskIntoConstraints="NO" id="nFQ-Jj-AE7">
<rect key="frame" x="177" y="14.5" width="20" height="20"/>
<constraints>
<constraint firstAttribute="height" constant="20" id="Klj-wp-rDJ"/>
<constraint firstAttribute="width" constant="20" id="yPY-dq-6S5"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="搜索" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ar6-48-fu9">
<rect key="frame" x="207" y="14.5" width="35" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" name="标题字颜色"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="Ar6-48-fu9" firstAttribute="leading" secondItem="nFQ-Jj-AE7" secondAttribute="trailing" constant="10" id="Dy3-92-fcK"/>
<constraint firstItem="Ar6-48-fu9" firstAttribute="centerY" secondItem="nFQ-Jj-AE7" secondAttribute="centerY" id="QCE-YL-Gae"/>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="44" id="ca1-th-cIc"/>
<constraint firstItem="nFQ-Jj-AE7" firstAttribute="centerX" secondItem="clr-t9-pBK" secondAttribute="centerX" constant="-20" id="ikV-DU-J3F"/>
<constraint firstAttribute="height" constant="49" id="jIi-G8-JNo"/>
<constraint firstItem="nFQ-Jj-AE7" firstAttribute="centerY" secondItem="clr-t9-pBK" secondAttribute="centerY" id="wQX-lW-no9"/>
</constraints>
</view>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="1gI-Ls-VbE">
<rect key="frame" x="0.0" y="108" width="414" height="705"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<connections>
<outlet property="dataSource" destination="-1" id="d6a-dm-laN"/>
<outlet property="delegate" destination="-1" id="KQt-4I-gy6"/>
</connections>
</tableView>
</subviews>
<viewLayoutGuide key="safeArea" id="Q5M-cg-NOt"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="Q5M-cg-NOt" firstAttribute="trailing" secondItem="1gI-Ls-VbE" secondAttribute="trailing" id="2rp-bZ-kcp"/>
<constraint firstAttribute="trailing" secondItem="icy-5U-c3o" secondAttribute="trailing" id="4MS-T0-M5h"/>
<constraint firstItem="1gI-Ls-VbE" firstAttribute="leading" secondItem="Q5M-cg-NOt" secondAttribute="leading" id="AmW-w1-exQ"/>
<constraint firstItem="icy-5U-c3o" firstAttribute="leading" secondItem="Q5M-cg-NOt" secondAttribute="leading" id="Enr-eO-mkc"/>
<constraint firstAttribute="trailing" secondItem="clr-t9-pBK" secondAttribute="trailing" id="Wjk-L9-o7w"/>
<constraint firstItem="Q5M-cg-NOt" firstAttribute="bottom" secondItem="clr-t9-pBK" secondAttribute="bottom" id="Wov-05-jYb"/>
<constraint firstItem="icy-5U-c3o" firstAttribute="top" secondItem="Q5M-cg-NOt" secondAttribute="top" id="aE1-re-Ajk"/>
<constraint firstItem="clr-t9-pBK" firstAttribute="leading" secondItem="Q5M-cg-NOt" secondAttribute="leading" id="aIs-YU-pZd"/>
<constraint firstItem="1gI-Ls-VbE" firstAttribute="top" secondItem="icy-5U-c3o" secondAttribute="bottom" id="hj8-al-Vzc"/>
<constraint firstItem="clr-t9-pBK" firstAttribute="top" secondItem="1gI-Ls-VbE" secondAttribute="bottom" id="tk0-od-NaT"/>
</constraints>
<point key="canvasLocation" x="14" y="119"/>
</view>
</objects>
<resources>
<image name="fanhui" width="18" height="35"/>
<image name="guanbi" width="37" height="18"/>
<namedColor name="标题字颜色">
<color red="0.18000000715255737" green="0.18000000715255737" blue="0.18000000715255737" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
//
// ConnectViewController.h
// BLETR
//
// Created by D500 user on 12/9/26.
// Copyright (c) 2012 ISSC Technologies Corporation. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "CBController.h"
#import "DeviceInfo.h"
@interface ConnectViewController : CBController<UITableViewDataSource, UITextViewDelegate, UITableViewDelegate>
{
IBOutlet UITableView *devicesTableView;
UIActivityIndicatorView *activityIndicatorView;
UILabel *statusLabel;
NSTimer *refreshDeviceListTimer;
int connectionStatus;
//Derek
DeviceInfo *deviceInfo;
MyPeripheral *controlPeripheral;
NSMutableArray *connectedDeviceInfo;//stored for DeviceInfo object
NSMutableArray *connectingList;//stored for MyPeripheral object
UIBarButtonItem *refreshButton;
UIBarButtonItem *scanButton;
UIBarButtonItem *cancelButton;
UIBarButtonItem *uuidSettingButton;
}
@property (nonatomic, retain) IBOutlet UIActivityIndicatorView *activityIndicatorView;
@property (nonatomic, retain) IBOutlet UILabel *statusLabel;
@property (assign) int connectionStatus;
@property (retain, nonatomic) IBOutlet UILabel *versionLabel;
- (IBAction)refreshDeviceList:(id)sender;
- (IBAction)actionButtonCancelScan:(id)sender;
- (IBAction)manualUUIDSetting:(id)sender;
- (IBAction)actionButtonDisconnect:(id)sender;
- (IBAction)actionButtonCancelConnect:(id)sender;
@end
//
// ConnectViewController.m
// BLETR
//
// Created by D500 user on 12/9/26.
// Copyright (c) 2012 ISSC Technologies Corporation. All rights reserved.
//
#import "ConnectViewController.h"
#import "BLKWrite.h"
#import "BabyBluetooth.h"
#import "Bt_Cell.h"
@interface ConnectViewController ()
@property (nonatomic, strong) BabyBluetooth *baby;
@property (nonatomic, strong) NSMutableArray *peripheralDataArray;
@property (nonatomic, strong) NSMutableArray *selectDataArray;
@property (nonatomic, strong) MyPeripheral *tempP;
@end
@implementation ConnectViewController
//@synthesize actionButton;
@synthesize activityIndicatorView;
@synthesize statusLabel;
@synthesize connectionStatus;
@synthesize versionLabel;
- (IBAction)backAction:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] init];
backButton.title = @"Back";
self.navigationItem.backBarButtonItem = backButton;
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(200, 28, 57, 57)];
[titleLabel setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"Icon_old"]]];
[titleLabel setTextAlignment:NSTextAlignmentCenter];//aaa
self.navigationItem.titleView = titleLabel;
connectedDeviceInfo = [NSMutableArray new];
connectingList = [NSMutableArray new];
deviceInfo = [[DeviceInfo alloc]init];
refreshDeviceListTimer = nil;
}
return self;
}
-(void)insertTableView:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData type:(int)type andManger:(CBManager*)m{
switch (type) {
case 0:
{[self.selectDataArray removeAllObjects];
[self.selectDataArray addObject:peripheral];
[devicesTableView reloadData];
[_baby cancelScan];}
break;
case 1:
{
if(![_peripheralDataArray containsObject:peripheral]){
NSMutableArray *indexPaths = [[NSMutableArray alloc] init];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:_peripheralDataArray.count inSection:0];
[indexPaths addObject:indexPath];
[_peripheralDataArray addObject:peripheral];
[devicesTableView reloadData];
}
}
break;
default:
{
[self.selectDataArray removeAllObjects];
[devicesTableView reloadData];
}
break;
}
}
-(void)babyDelegate{
//设置扫描到设备的委托
[_baby setBlockOnDiscoverToPeripherals:^(CBCentralManager *central, CBPeripheral *peripheral, NSDictionary *advertisementData, NSNumber *RSSI) {
NSLog(@"搜索到了设备:%@",peripheral.name);
}];
//过滤器
//设置查找设备的过滤器
[_baby setFilterOnDiscoverPeripherals:^BOOL(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI) {
//最常用的场景是查找某一个前缀开头的设备 most common usage is discover for peripheral that name has common prefix
if (peripheralName.length != 0) {
return YES;
}
return NO;
}];
__weak typeof(self) weakSelf = self;
[_baby setBlockOnDiscoverToPeripherals:^(CBCentralManager *central, CBPeripheral *peripheral, NSDictionary *advertisementData, NSNumber *RSSI) {
if (peripheral.name.length != 0) {
[weakSelf insertTableView:peripheral advertisementData:advertisementData type:1 andManger:NULL];
}
}];
[_baby setBlockOnConnected:^(CBCentralManager *central, CBPeripheral *peripheral) {
if (peripheral.name.length != 0) {
[weakSelf insertTableView:peripheral advertisementData:NULL type:0 andManger:NULL];
}
}];
[_baby setBlockOnFailToConnect:^(CBCentralManager *central, CBPeripheral *peripheral, NSError *error) {
}];
[_baby setBlockOnCancelAllPeripheralsConnectionBlock:^(CBCentralManager *centralManager) {
[weakSelf insertTableView:NULL advertisementData:NULL type:2 andManger:centralManager];
}];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
[self setConnectionStatus:LE_STATUS_IDLE];
[versionLabel setText:[NSString stringWithFormat:@"BLETR %@, %s",[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"], __DATE__]];
[devicesTableView registerNib:[UINib nibWithNibName:@"Bt_Cell" bundle:NULL] forCellReuseIdentifier:@"Bt_Cell"];
_peripheralDataArray = [NSMutableArray array];
_selectDataArray = [NSMutableArray array];
_baby = [BabyBluetooth shareBabyBluetooth];
[_baby scanForPeripherals];
[_baby begin];
[self babyDelegate];
}
- (void)viewDidAppear:(BOOL)animated {
[self startScan];
}
- (void)viewDidUnload
{
devicesTableView = nil;
[self setVersionLabel:nil];
refreshButton = nil;
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
NSLog(@"[ConnectViewController] didReceiveMemoryWarning");
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void) displayDevicesList {
[devicesTableView reloadData];
}
- (void) switchToMainFeaturePage {
NSLog(@"[ConnectViewController] switchToMainFeaturePage");
// AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
// if ([[[appDelegate navigationController] viewControllers] containsObject:[deviceInfo mainViewController]] == FALSE) {
// [[appDelegate navigationController] pushViewController:[deviceInfo mainViewController] animated:YES];
// }
}
- (int) connectionStatus {
return connectionStatus;
}
- (void) setConnectionStatus:(int)status {
if (status == LE_STATUS_IDLE) {
statusLabel.textColor = [UIColor redColor];
}
else {
statusLabel.textColor = [UIColor blackColor];
}
connectionStatus = status;
switch (status) {
case LE_STATUS_IDLE:
statusLabel.text = @"Idle";
[activityIndicatorView stopAnimating];
break;
case LE_STATUS_SCANNING:
[devicesTableView reloadData];
statusLabel.text = @"Scanning...";
[activityIndicatorView startAnimating];
break;
default:
break;
}
[self updateButtonType];
}
- (IBAction)actionButtonCancelScan:(id)sender {
NSLog(@"[ConnectViewController] actionButtonCancelScan");
[self stopScan];
[self setConnectionStatus:LE_STATUS_IDLE];
}
- (void)startScan {
[super startScan];
if ([connectingList count] > 0) {
for (int i=0; i< [connectingList count]; i++) {
MyPeripheral *connectingPeripheral = [connectingList objectAtIndex:i];
if (connectingPeripheral.connectStaus == MYPERIPHERAL_CONNECT_STATUS_CONNECTING) {
//NSLog(@"startScan add connecting List: %@",connectingPeripheral.advName);
[devicesList addObject:connectingPeripheral];
}
else {
[connectingList removeObjectAtIndex:i];
//NSLog(@"startScan remove connecting List: %@",connectingPeripheral.advName);
}
}
}
[self setConnectionStatus:LE_STATUS_SCANNING];
}
- (void)stopScan {
[super stopScan];
if (refreshDeviceListTimer) {
[refreshDeviceListTimer invalidate];
refreshDeviceListTimer = nil;
}
}
-(void)popToRootPage {
// AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
// if (appDelegate.pageTransition == FALSE) {
// [[appDelegate navigationController] popToRootViewControllerAnimated:NO];
// }
// else {
// [NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(popToRootPage) userInfo:nil repeats:NO];
// }
}
- (void)updateDiscoverPeripherals {
[super updateDiscoverPeripherals];
[devicesTableView reloadData];
}
- (void)updateMyPeripheralForDisconnect:(MyPeripheral *)myPeripheral {
NSLog(@"updateMyPeripheralForDisconnect");//, %@", myPeripheral.advName);
if (myPeripheral == controlPeripheral) {
[NSTimer scheduledTimerWithTimeInterval:0.03 target:self selector:@selector(popToRootPage) userInfo:nil repeats:NO];
}
for (int idx =0; idx< [connectedDeviceInfo count]; idx++) {
DeviceInfo *tmpDeviceInfo = [connectedDeviceInfo objectAtIndex:idx];
if (tmpDeviceInfo.myPeripheral == myPeripheral) {
[connectedDeviceInfo removeObjectAtIndex:idx];
//NSLog(@"updateMyPeripheralForDisconnect1");
break;
}
}
for (int idx =0; idx< [connectingList count]; idx++) {
MyPeripheral *tmpPeripheral = [connectingList objectAtIndex:idx];
if (tmpPeripheral == myPeripheral) {
[connectingList removeObjectAtIndex:idx];
//NSLog(@"updateMyPeripheralForDisconnect2");
break;
}
else{
//NSLog(@"updateMyPeripheralForDisconnect3 %@, %@", tmpPeripheral.advName, myPeripheral.advName);
}
}
[self displayDevicesList];
[self updateButtonType];
if(connectionStatus == LE_STATUS_SCANNING){
[self stopScan];
[self startScan];
[devicesTableView reloadData];
}
}
- (void)updateMyPeripheralForNewConnected:(MyPeripheral *)myPeripheral {
[[BLKWrite Instance] setPeripheral:myPeripheral];
NSLog(@"[ConnectViewController] updateMyPeripheralForNewConnected");
DeviceInfo *tmpDeviceInfo = [[DeviceInfo alloc]init];
// tmpDeviceInfo.mainViewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
// tmpDeviceInfo.mainViewController.connectedPeripheral = myPeripheral;
tmpDeviceInfo.myPeripheral = myPeripheral;
tmpDeviceInfo.myPeripheral.connectStaus = myPeripheral.connectStaus;
/*Connected List Filter*/
bool b = FALSE;
for (int idx =0; idx< [connectedDeviceInfo count]; idx++) {
DeviceInfo *tmpDeviceInfo = [connectedDeviceInfo objectAtIndex:idx];
if (tmpDeviceInfo.myPeripheral == myPeripheral) {
b = TRUE;
break;
}
}
if (!b) {
[connectedDeviceInfo addObject:tmpDeviceInfo];
}
else{
NSLog(@"Connected List Filter!");
}
for (int idx =0; idx< [connectingList count]; idx++) {
MyPeripheral *tmpPeripheral = [connectingList objectAtIndex:idx];
if (tmpPeripheral == myPeripheral) {
//NSLog(@"connectingList removeObject:%@",tmpPeripheral.advName);
[connectingList removeObjectAtIndex:idx];
break;
}
}
for (int idx =0; idx< [devicesList count]; idx++) {
MyPeripheral *tmpPeripheral = [devicesList objectAtIndex:idx];
if (tmpPeripheral == myPeripheral) {
//NSLog(@"devicesList removeObject:%@",tmpPeripheral.advName);
[devicesList removeObjectAtIndex:idx];
break;
}
}
[self displayDevicesList];
[self updateButtonType];
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 44;
}
// DataSource methods
- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
//NSLog(@"[ConnectViewController] numberOfRowsInSection,device count = %d", [devicesList count]);
if (section == 0) {
return _selectDataArray.count;
}
return _peripheralDataArray.count;
}
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
Bt_Cell *cell = [tableView dequeueReusableCellWithIdentifier:@"Bt_Cell"];
switch (indexPath.section) {
case 0:
{
CBPeripheral *tmpDeviceInfo = [_selectDataArray objectAtIndex:indexPath.row];
cell.title_lbl.text = tmpDeviceInfo.name;
cell.statusImg.hidden = NO;
}
break;
case 1:
{
CBPeripheral *tmpPeripheral = [_peripheralDataArray objectAtIndex:indexPath.row];
cell.title_lbl.text = tmpPeripheral.name;
cell.statusImg.hidden = YES;
}
break;
}
return cell;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 46)];
view.backgroundColor = [UIColor colorNamed:@"app底色"];
UILabel *lbl = [[UILabel alloc]initWithFrame:CGRectMake(15, 0, self.view.bounds.size.width, 46)];
lbl.font = [UIFont boldSystemFontOfSize:11];
lbl.textColor = [UIColor colorNamed:@"灰色字体颜色"];
[view addSubview:lbl];
switch (section) {
case 0:
{
lbl.text = @"选择已经连接的设备作为默认打印设备";
}
break;
default:
{
lbl.text = @"选择设备进行连接";
}
break;
}
return view;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 46;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 46;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 46)];
view.backgroundColor = [UIColor colorNamed:@"app底色"];
UILabel *lbl = [[UILabel alloc]initWithFrame:CGRectMake(15, 0, self.view.bounds.size.width, 46)];
lbl.font = [UIFont boldSystemFontOfSize:15];
lbl.textColor = [UIColor colorNamed:@"灰色字体颜色"];
[view addSubview:lbl];
switch (section) {
case 0:
{
lbl.text = @"已连接设备";
}
break;
default:
{
lbl.text = @"未连接设备";
}
break;
}
return view;
}
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView{
return 2;
}
/*
if (indexPath.section == 0) {
[_baby cancelAllPeripheralsConnection];
}else{
CBPeripheral *p = _peripheralDataArray[indexPath.row];
[[[[[[_baby having:p]and]channel:@"peripheralView"]then]connectToPeripherals]begin];
}
*/
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
switch (indexPath.section) {
case 0:
{
//NSLog(@"[ConnectViewController] didSelectRowAtIndexPath section 0, Row = %d",[indexPath row]);
[_baby cancelAllPeripheralsConnection];
[self disconnectDevice:_tempP];
deviceInfo = [connectedDeviceInfo objectAtIndex:indexPath.row];
controlPeripheral = deviceInfo.myPeripheral;
[self stopScan];
[self setConnectionStatus:LE_STATUS_IDLE];
[activityIndicatorView stopAnimating];
if (refreshDeviceListTimer) {
[refreshDeviceListTimer invalidate];
refreshDeviceListTimer = nil;
}
}
break;
case 1:
{
CBPeripheral *p = _peripheralDataArray[indexPath.row];
[[[[[[_baby having:p]and]channel:@"peripheralView"]then]connectToPeripherals]begin];
int count = [devicesList count];
if ((count != 0) && count > indexPath.row) {
for (int i = 0; i < devicesList.count; i++) {
MyPeripheral *mp = devicesList[i];
if ([p.name isEqualToString:mp.advName]) {
MyPeripheral *tmpPeripheral = [devicesList objectAtIndex:i];
if (tmpPeripheral.connectStaus != MYPERIPHERAL_CONNECT_STATUS_IDLE) {
break;
}
[self connectDevice:tmpPeripheral];
self.tempP = tmpPeripheral;
tmpPeripheral.connectStaus = MYPERIPHERAL_CONNECT_STATUS_CONNECTING;
[devicesList replaceObjectAtIndex:i withObject:tmpPeripheral];
[connectingList addObject:tmpPeripheral];
[self displayDevicesList];
[self updateButtonType];
}
}
}
break;
}
default:
break;
}
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
- (IBAction)refreshDeviceList:(id)sender {
NSLog(@"[ConnectViewController] refreshDeviceList");
[self stopScan];
[self startScan];
[devicesTableView reloadData];
}
- (IBAction)manualUUIDSetting:(id)sender {
}
//Derek
- (IBAction)actionButtonDisconnect:(id)sender {
//NSLog(@"[ConnectViewController] actionButtonDisconnect idx = %d",[sender tag]);
int idx = [sender tag];
DeviceInfo *tmpDeviceInfo = [connectedDeviceInfo objectAtIndex:idx];
[self disconnectDevice:tmpDeviceInfo.myPeripheral];
}
//Derek
- (IBAction)actionButtonCancelConnect:(id)sender {
//NSLog(@"[ConnectViewController] actionButtonCancelConnect idx = %d",[sender tag]);
int idx = [sender tag];
MyPeripheral *tmpPeripheral = [devicesList objectAtIndex:idx];
tmpPeripheral.connectStaus = MYPERIPHERAL_CONNECT_STATUS_IDLE;
[devicesList replaceObjectAtIndex:idx withObject:tmpPeripheral];
for (int idx =0; idx< [connectingList count]; idx++) {
MyPeripheral *tmpConnectingPeripheral = [connectingList objectAtIndex:idx];
if (tmpConnectingPeripheral == tmpPeripheral) {
[connectingList removeObjectAtIndex:idx];
break;
}
}
[self disconnectDevice:tmpPeripheral];
[self displayDevicesList];
[self updateButtonType];
}
- (void) updateButtonType {
NSArray *toolbarItems = nil;
switch (connectionStatus) {
case LE_STATUS_IDLE:
if (([connectedDeviceInfo count] > 0)||([connectingList count] > 0)) {
toolbarItems = [[NSArray alloc] initWithObjects:scanButton, nil];
}
else {
toolbarItems = [[NSArray alloc] initWithObjects:scanButton, uuidSettingButton, nil];
}
[self setToolbarItems:toolbarItems animated:NO];
break;
case LE_STATUS_SCANNING:
if (([connectedDeviceInfo count] > 0)||([connectingList count] > 0)) {
toolbarItems = [[NSArray alloc] initWithObjects:refreshButton,cancelButton , nil];
}
else {
toolbarItems = [[NSArray alloc] initWithObjects: refreshButton,cancelButton, uuidSettingButton, nil];
}
[self setToolbarItems:toolbarItems animated:NO];
break;
}
}
@end
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment version="4352" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ConnectViewController">
<connections>
<outlet property="devicesTableView" destination="28" id="46"/>
<outlet property="view" destination="1" id="3"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="1">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="10" sectionFooterHeight="10" translatesAutoresizingMaskIntoConstraints="NO" id="28">
<rect key="frame" x="0.0" y="108" width="414" height="710"/>
<color key="backgroundColor" name="app底色"/>
<color key="tintColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<connections>
<outlet property="dataSource" destination="-1" id="53"/>
<outlet property="delegate" destination="-1" id="54"/>
</connections>
</tableView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="zc7-AT-gpf">
<rect key="frame" x="0.0" y="44" width="414" height="64"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="spF-M4-7iJ">
<rect key="frame" x="0.0" y="0.0" width="414" height="64"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="蓝牙打印设置" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Lgw-vw-Sbp">
<rect key="frame" x="156" y="20" width="102" height="24"/>
<fontDescription key="fontDescription" name="PingFangSC-Medium" family="PingFang SC" pointSize="17"/>
<color key="textColor" name="标题字颜色"/>
<nil key="highlightedColor"/>
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="fanhui" translatesAutoresizingMaskIntoConstraints="NO" id="Mgw-x4-J8K">
<rect key="frame" x="12" y="23.5" width="10" height="17"/>
<constraints>
<constraint firstAttribute="width" constant="10" id="Hq8-rP-LiI"/>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="17" id="ccw-RM-qQY"/>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="10" id="l7B-HV-zKn"/>
<constraint firstAttribute="height" constant="17" id="v2d-QL-B55"/>
</constraints>
</imageView>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="chl-ZP-eLe">
<rect key="frame" x="0.0" y="1" width="46" height="64"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="46" id="axe-wp-cmb"/>
<constraint firstAttribute="width" constant="46" id="eFl-tD-hbH"/>
</constraints>
<connections>
<action selector="backAction:" destination="-1" eventType="touchUpInside" id="Thg-CB-Z6H"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="chl-ZP-eLe" firstAttribute="top" secondItem="spF-M4-7iJ" secondAttribute="top" id="KYW-vo-glX"/>
<constraint firstItem="Mgw-x4-J8K" firstAttribute="leading" secondItem="spF-M4-7iJ" secondAttribute="leading" constant="12" id="NYw-2V-UX4"/>
<constraint firstAttribute="bottom" secondItem="chl-ZP-eLe" secondAttribute="bottom" id="OWq-2b-E9Q"/>
<constraint firstItem="Mgw-x4-J8K" firstAttribute="centerY" secondItem="spF-M4-7iJ" secondAttribute="centerY" id="PSf-91-fLa"/>
<constraint firstItem="Lgw-vw-Sbp" firstAttribute="centerX" secondItem="spF-M4-7iJ" secondAttribute="centerX" id="TVi-GH-1rj"/>
<constraint firstItem="Lgw-vw-Sbp" firstAttribute="centerY" secondItem="spF-M4-7iJ" secondAttribute="centerY" id="kJE-eX-cBy"/>
<constraint firstItem="chl-ZP-eLe" firstAttribute="leading" secondItem="spF-M4-7iJ" secondAttribute="leading" id="smr-Ef-DQk"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstAttribute="height" constant="64" id="MqQ-Xt-QIT"/>
<constraint firstItem="spF-M4-7iJ" firstAttribute="leading" secondItem="zc7-AT-gpf" secondAttribute="leading" id="QYV-ET-WTR"/>
<constraint firstItem="spF-M4-7iJ" firstAttribute="top" secondItem="zc7-AT-gpf" secondAttribute="top" id="aLg-iZ-MLQ"/>
<constraint firstAttribute="bottom" secondItem="spF-M4-7iJ" secondAttribute="bottom" id="hoa-Kq-MGg"/>
<constraint firstAttribute="trailing" secondItem="spF-M4-7iJ" secondAttribute="trailing" id="mIT-IF-pbd"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="xke-2d-5B5">
<rect key="frame" x="0.0" y="818" width="414" height="44"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="gqi-gf-0In">
<rect key="frame" x="0.0" y="-2.5" width="414" height="49"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="guanbi" translatesAutoresizingMaskIntoConstraints="NO" id="vdm-VH-b5J">
<rect key="frame" x="177" y="14.5" width="20" height="20"/>
<constraints>
<constraint firstAttribute="width" constant="20" id="UlG-OZ-nTe"/>
<constraint firstAttribute="height" constant="20" id="WDa-RN-4J9"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="搜索" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ebL-OX-bfW">
<rect key="frame" x="207" y="14.5" width="35" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" name="标题字颜色"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstAttribute="height" constant="49" id="MvF-b3-LGa"/>
<constraint firstItem="vdm-VH-b5J" firstAttribute="centerX" secondItem="gqi-gf-0In" secondAttribute="centerX" constant="-20" id="YrR-R5-xhU"/>
<constraint firstItem="ebL-OX-bfW" firstAttribute="leading" secondItem="vdm-VH-b5J" secondAttribute="trailing" constant="10" id="aKo-Gc-v3g"/>
<constraint firstItem="ebL-OX-bfW" firstAttribute="centerY" secondItem="vdm-VH-b5J" secondAttribute="centerY" id="dDG-fj-ecl"/>
<constraint firstItem="vdm-VH-b5J" firstAttribute="centerY" secondItem="gqi-gf-0In" secondAttribute="centerY" id="e6N-up-PnV"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="gqi-gf-0In" firstAttribute="centerY" secondItem="xke-2d-5B5" secondAttribute="centerY" id="CmP-w7-N0l"/>
<constraint firstItem="gqi-gf-0In" firstAttribute="centerX" secondItem="xke-2d-5B5" secondAttribute="centerX" id="UJp-R9-oW7"/>
<constraint firstItem="gqi-gf-0In" firstAttribute="leading" secondItem="xke-2d-5B5" secondAttribute="leading" id="mJE-kP-age"/>
<constraint firstAttribute="height" constant="44" id="ryw-xf-FRE"/>
</constraints>
</view>
</subviews>
<viewLayoutGuide key="safeArea" id="HXX-bU-QRe"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="zc7-AT-gpf" secondAttribute="trailing" id="07w-nU-nc9"/>
<constraint firstItem="HXX-bU-QRe" firstAttribute="trailing" secondItem="xke-2d-5B5" secondAttribute="trailing" id="3mx-8t-3LC"/>
<constraint firstItem="28" firstAttribute="leading" secondItem="HXX-bU-QRe" secondAttribute="leading" id="4ci-2j-lSW"/>
<constraint firstItem="HXX-bU-QRe" firstAttribute="bottom" secondItem="xke-2d-5B5" secondAttribute="bottom" id="KP1-r0-TPX"/>
<constraint firstItem="zc7-AT-gpf" firstAttribute="top" secondItem="HXX-bU-QRe" secondAttribute="top" id="Znt-J0-udl"/>
<constraint firstItem="xke-2d-5B5" firstAttribute="leading" secondItem="HXX-bU-QRe" secondAttribute="leading" id="aQn-pW-pMy"/>
<constraint firstItem="28" firstAttribute="trailing" secondItem="HXX-bU-QRe" secondAttribute="trailing" id="naT-s9-z71"/>
<constraint firstItem="zc7-AT-gpf" firstAttribute="leading" secondItem="1" secondAttribute="leading" id="pcg-rj-Zej"/>
<constraint firstItem="28" firstAttribute="top" secondItem="zc7-AT-gpf" secondAttribute="bottom" id="rwk-gj-md2"/>
<constraint firstItem="xke-2d-5B5" firstAttribute="top" secondItem="28" secondAttribute="bottom" id="ttm-3p-BSZ"/>
</constraints>
<point key="canvasLocation" x="98.550724637681171" y="118.52678571428571"/>
</view>
</objects>
<resources>
<image name="fanhui" width="18" height="35"/>
<image name="guanbi" width="37" height="18"/>
<namedColor name="app底色">
<color red="0.94509803921568625" green="0.94509803921568625" blue="0.94509803921568625" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="标题字颜色">
<color red="0.18000000715255737" green="0.18000000715255737" blue="0.18000000715255737" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment