Skip to content

Commit 6697454

Browse files
committed
Error: invalid numeric value to CoreGraphics API #1
1 parent 2e69aa8 commit 6697454

File tree

8 files changed

+87
-23
lines changed

8 files changed

+87
-23
lines changed

LMGaugeView.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = "LMGaugeView"
4-
s.version = "1.0.0"
4+
s.version = "1.0.1"
55
s.summary = "LMGaugeView is a simple and customizable gauge control for iOS."
66
s.homepage = "https://github.com/lminhtm/LMGaugeView"
77
s.license = 'MIT'

LMGaugeView/LMGaugeView.m

+7-7
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ - (void)strokeGauge
127127
/*!
128128
* Set progress for ring layer
129129
*/
130-
CGFloat progress = (self.value - self.minValue)/self.maxValue;
130+
CGFloat progress = self.maxValue ? (self.value - self.minValue)/self.maxValue : 0;
131131
self.progressLayer.strokeEnd = progress;
132132

133133
/*!
@@ -148,8 +148,8 @@ - (void)drawRect:(CGRect)rect
148148
/*!
149149
* Prepare drawing
150150
*/
151-
self.divisionUnitValue = (self.maxValue - self.minValue)/self.numOfDivisions;
152-
self.divisionUnitAngle = (M_PI * 2 - ABS(self.endAngle - self.startAngle))/self.numOfDivisions;
151+
self.divisionUnitValue = self.numOfDivisions ? (self.maxValue - self.minValue)/self.numOfDivisions : 0;
152+
self.divisionUnitAngle = self.numOfDivisions ? (M_PI * 2 - ABS(self.endAngle - self.startAngle))/self.numOfDivisions : 0;
153153
CGPoint center = CGPointMake(CGRectGetWidth(self.bounds)/2, CGRectGetHeight(self.bounds)/2);
154154
CGFloat ringRadius = MIN(CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds))/2 - self.ringThickness/2;
155155
CGFloat dotRadius = ringRadius - self.ringThickness/2 - self.divisionsPadding - self.divisionsRadius/2;
@@ -176,11 +176,11 @@ - (void)drawRect:(CGRect)rect
176176
/*!
177177
* Draw divisions and subdivisions
178178
*/
179-
for (int i = 0; i <= self.numOfDivisions; i++)
179+
for (int i = 0; i <= self.numOfDivisions && self.numOfDivisions != 0; i++)
180180
{
181181
if (i != self.numOfDivisions)
182182
{
183-
for (int j = 0; j <= self.numOfSubDivisions; j++)
183+
for (int j = 0; j <= self.numOfSubDivisions && self.numOfSubDivisions != 0; j++)
184184
{
185185
// Subdivisions
186186
CGFloat value = i * self.divisionUnitValue + j * self.divisionUnitValue/self.numOfSubDivisions;
@@ -206,7 +206,7 @@ - (void)drawRect:(CGRect)rect
206206
/*!
207207
* Draw the limit dot
208208
*/
209-
if (self.showLimitDot)
209+
if (self.showLimitDot && self.numOfDivisions != 0)
210210
{
211211
CGFloat angle = [self angleFromValue:self.limitValue];
212212
CGPoint dotCenter = CGPointMake(dotRadius * cos(angle) + center.x, dotRadius * sin(angle) + center.y);
@@ -288,7 +288,7 @@ - (void)drawRect:(CGRect)rect
288288

289289
- (CGFloat)angleFromValue:(CGFloat)value
290290
{
291-
CGFloat level = ((value - self.minValue)/self.divisionUnitValue);
291+
CGFloat level = self.divisionUnitValue ? (value - self.minValue)/self.divisionUnitValue : 0;
292292
CGFloat angle = level * self.divisionUnitAngle + self.startAngle;
293293
return angle;
294294
}

LMGaugeViewDemo/LMGaugeViewDemo.xcodeproj/project.pbxproj

+8-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
5C8E55721BF977A0009C38FC /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5C8E55711BF977A0009C38FC /* Launch Screen.storyboard */; };
1011
5CE9FFE71B6C7058004C633B /* LMGaugeView.m in Sources */ = {isa = PBXBuildFile; fileRef = 5CE9FFE61B6C7058004C633B /* LMGaugeView.m */; };
1112
62166421198AB252009AD267 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 62166420198AB252009AD267 /* Foundation.framework */; };
1213
62166423198AB252009AD267 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 62166422198AB252009AD267 /* CoreGraphics.framework */; };
@@ -20,6 +21,7 @@
2021
/* End PBXBuildFile section */
2122

2223
/* Begin PBXFileReference section */
24+
5C8E55711BF977A0009C38FC /* Launch Screen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = "Launch Screen.storyboard"; sourceTree = "<group>"; };
2325
5CE9FFE51B6C7058004C633B /* LMGaugeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LMGaugeView.h; sourceTree = "<group>"; };
2426
5CE9FFE61B6C7058004C633B /* LMGaugeView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LMGaugeView.m; sourceTree = "<group>"; };
2527
6216641D198AB252009AD267 /* LMGaugeView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LMGaugeView.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -107,6 +109,7 @@
107109
isa = PBXGroup;
108110
children = (
109111
62166438198AB252009AD267 /* Images.xcassets */,
112+
5C8E55711BF977A0009C38FC /* Launch Screen.storyboard */,
110113
62166428198AB252009AD267 /* LMGaugeViewDemo-Info.plist */,
111114
62166429198AB252009AD267 /* InfoPlist.strings */,
112115
6216642C198AB252009AD267 /* main.m */,
@@ -142,7 +145,7 @@
142145
isa = PBXProject;
143146
attributes = {
144147
CLASSPREFIX = LM;
145-
LastUpgradeCheck = 0510;
148+
LastUpgradeCheck = 0710;
146149
ORGANIZATIONNAME = LMinh;
147150
};
148151
buildConfigurationList = 62166418198AB252009AD267 /* Build configuration list for PBXProject "LMGaugeViewDemo" */;
@@ -170,6 +173,7 @@
170173
files = (
171174
62166439198AB252009AD267 /* Images.xcassets in Resources */,
172175
6216642B198AB252009AD267 /* InfoPlist.strings in Resources */,
176+
5C8E55721BF977A0009C38FC /* Launch Screen.storyboard in Resources */,
173177
62166434198AB252009AD267 /* Main.storyboard in Resources */,
174178
);
175179
runOnlyForDeploymentPostprocessing = 0;
@@ -228,6 +232,7 @@
228232
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
229233
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
230234
COPY_PHASE_STRIP = NO;
235+
ENABLE_TESTABILITY = YES;
231236
GCC_C_LANGUAGE_STANDARD = gnu99;
232237
GCC_DYNAMIC_NO_PIC = NO;
233238
GCC_OPTIMIZATION_LEVEL = 0;
@@ -289,6 +294,7 @@
289294
GCC_PREFIX_HEADER = "LMGaugeViewDemo/LMGaugeViewDemo-Prefix.pch";
290295
INFOPLIST_FILE = "LMGaugeViewDemo/LMGaugeViewDemo-Info.plist";
291296
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
297+
PRODUCT_BUNDLE_IDENTIFIER = "com.lminh.${PRODUCT_NAME:rfc1034identifier}";
292298
PRODUCT_NAME = LMGaugeView;
293299
WRAPPER_EXTENSION = app;
294300
};
@@ -303,6 +309,7 @@
303309
GCC_PREFIX_HEADER = "LMGaugeViewDemo/LMGaugeViewDemo-Prefix.pch";
304310
INFOPLIST_FILE = "LMGaugeViewDemo/LMGaugeViewDemo-Info.plist";
305311
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
312+
PRODUCT_BUNDLE_IDENTIFIER = "com.lminh.${PRODUCT_NAME:rfc1034identifier}";
306313
PRODUCT_NAME = LMGaugeView;
307314
WRAPPER_EXTENSION = app;
308315
};

LMGaugeViewDemo/LMGaugeViewDemo.xcodeproj/xcuserdata/lminh.xcuserdatad/xcschemes/LMGaugeViewDemo.xcscheme

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0640"
3+
LastUpgradeVersion = "0710"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -23,10 +23,10 @@
2323
</BuildActionEntries>
2424
</BuildAction>
2525
<TestAction
26+
buildConfiguration = "Debug"
2627
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2728
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
28-
shouldUseLaunchSchemeArgsEnv = "YES"
29-
buildConfiguration = "Debug">
29+
shouldUseLaunchSchemeArgsEnv = "YES">
3030
<Testables>
3131
</Testables>
3232
<MacroExpansion>
@@ -38,15 +38,18 @@
3838
ReferencedContainer = "container:LMGaugeViewDemo.xcodeproj">
3939
</BuildableReference>
4040
</MacroExpansion>
41+
<AdditionalOptions>
42+
</AdditionalOptions>
4143
</TestAction>
4244
<LaunchAction
45+
buildConfiguration = "Debug"
4346
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4447
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
4548
launchStyle = "0"
4649
useCustomWorkingDirectory = "NO"
47-
buildConfiguration = "Debug"
4850
ignoresPersistentStateOnLaunch = "NO"
4951
debugDocumentVersioning = "YES"
52+
debugServiceExtension = "internal"
5053
allowLocationSimulation = "YES">
5154
<BuildableProductRunnable
5255
runnableDebuggingMode = "0">
@@ -62,10 +65,10 @@
6265
</AdditionalOptions>
6366
</LaunchAction>
6467
<ProfileAction
68+
buildConfiguration = "Release"
6569
shouldUseLaunchSchemeArgsEnv = "YES"
6670
savedToolIdentifier = ""
6771
useCustomWorkingDirectory = "NO"
68-
buildConfiguration = "Release"
6972
debugDocumentVersioning = "YES">
7073
<BuildableProductRunnable
7174
runnableDebuggingMode = "0">

LMGaugeViewDemo/LMGaugeViewDemo/Base.lproj/Main.storyboard

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="vXZ-lx-hvc">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9059" systemVersion="15A284" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="vXZ-lx-hvc">
33
<dependencies>
44
<deployment identifier="iOS"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9049"/>
66
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
77
</dependencies>
88
<scenes>
9-
<!--View Controller-->
9+
<!--Delegate-->
1010
<scene sceneID="ufC-wZ-h7g">
1111
<objects>
1212
<viewController id="vXZ-lx-hvc" customClass="LMViewController" sceneMemberID="viewController">
@@ -20,6 +20,7 @@
2020
<subviews>
2121
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="UgZ-WN-tPe" customClass="LMGaugeView">
2222
<rect key="frame" x="20" y="114" width="280" height="280"/>
23+
<animations/>
2324
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
2425
<constraints>
2526
<constraint firstAttribute="width" secondItem="UgZ-WN-tPe" secondAttribute="height" multiplier="1:1" id="x0s-rf-4tG"/>
@@ -38,12 +39,14 @@
3839
</view>
3940
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="IR3-O8-TRX">
4041
<rect key="frame" x="134" y="487" width="51" height="31"/>
42+
<animations/>
4143
<connections>
4244
<action selector="changedStyleSwitchValueChanged:" destination="vXZ-lx-hvc" eventType="valueChanged" id="Kq5-AS-1ZL"/>
4345
</connections>
4446
</switch>
4547
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Developed by LMinh" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="DcH-fn-VJ8" userLabel="Label - About">
4648
<rect key="frame" x="20" y="538" width="280" height="20"/>
49+
<animations/>
4750
<constraints>
4851
<constraint firstAttribute="height" constant="20" id="jQR-oE-QbD"/>
4952
</constraints>
@@ -52,6 +55,7 @@
5255
<nil key="highlightedColor"/>
5356
</label>
5457
</subviews>
58+
<animations/>
5559
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
5660
<constraints>
5761
<constraint firstItem="2fi-mo-0CV" firstAttribute="top" secondItem="DcH-fn-VJ8" secondAttribute="bottom" constant="10" id="8Oe-gH-qFC"/>
@@ -76,9 +80,4 @@
7680
<point key="canvasLocation" x="-12" y="358"/>
7781
</scene>
7882
</scenes>
79-
<simulatedMetricsContainer key="defaultSimulatedMetrics">
80-
<simulatedStatusBarMetrics key="statusBar"/>
81-
<simulatedOrientationMetrics key="orientation"/>
82-
<simulatedScreenMetrics key="destination" type="retina4"/>
83-
</simulatedMetricsContainer>
8483
</document>

LMGaugeViewDemo/LMGaugeViewDemo/LMGaugeViewDemo-Info.plist

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<key>CFBundleExecutable</key>
1010
<string>${EXECUTABLE_NAME}</string>
1111
<key>CFBundleIdentifier</key>
12-
<string>com.lminh.${PRODUCT_NAME:rfc1034identifier}</string>
12+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
1313
<key>CFBundleInfoDictionaryVersion</key>
1414
<string>6.0</string>
1515
<key>CFBundleName</key>
@@ -24,6 +24,8 @@
2424
<string>1.0</string>
2525
<key>LSRequiresIPhoneOS</key>
2626
<true/>
27+
<key>UILaunchStoryboardName</key>
28+
<string>Launch Screen</string>
2729
<key>UIMainStoryboardFile</key>
2830
<string>Main</string>
2931
<key>UIRequiredDeviceCapabilities</key>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9059" systemVersion="15A284" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
3+
<dependencies>
4+
<deployment identifier="iOS"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9049"/>
6+
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
7+
</dependencies>
8+
<scenes>
9+
<!--View Controller-->
10+
<scene sceneID="EHf-IW-A2E">
11+
<objects>
12+
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
13+
<layoutGuides>
14+
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
15+
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
16+
</layoutGuides>
17+
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
18+
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
19+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
20+
<subviews>
21+
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright © 2015 LMinh. All rights reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="obG-Y5-kRd">
22+
<rect key="frame" x="20" y="559" width="560" height="21"/>
23+
<animations/>
24+
<fontDescription key="fontDescription" type="system" pointSize="17"/>
25+
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
26+
<nil key="highlightedColor"/>
27+
</label>
28+
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="LMGaugeViewDemo" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="GJd-Yh-RWb">
29+
<rect key="frame" x="20" y="180" width="560" height="43"/>
30+
<animations/>
31+
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
32+
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
33+
<nil key="highlightedColor"/>
34+
</label>
35+
</subviews>
36+
<animations/>
37+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
38+
<constraints>
39+
<constraint firstAttribute="centerX" secondItem="obG-Y5-kRd" secondAttribute="centerX" id="5cz-MP-9tL"/>
40+
<constraint firstAttribute="centerX" secondItem="GJd-Yh-RWb" secondAttribute="centerX" id="Q3B-4B-g5h"/>
41+
<constraint firstItem="obG-Y5-kRd" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" constant="20" symbolic="YES" id="SfN-ll-jLj"/>
42+
<constraint firstAttribute="bottom" secondItem="obG-Y5-kRd" secondAttribute="bottom" constant="20" id="Y44-ml-fuU"/>
43+
<constraint firstItem="GJd-Yh-RWb" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="bottom" multiplier="1/3" constant="1" id="moa-c2-u7t"/>
44+
<constraint firstItem="GJd-Yh-RWb" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" constant="20" symbolic="YES" id="x7j-FC-K8j"/>
45+
</constraints>
46+
</view>
47+
</viewController>
48+
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
49+
</objects>
50+
<point key="canvasLocation" x="371" y="372"/>
51+
</scene>
52+
</scenes>
53+
</document>

0 commit comments

Comments
 (0)