Эх сурвалжийг харах

170209

Change Signature add line width setting.
Ray Zhang 9 жил өмнө
parent
commit
88fa9a33b8

BIN
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/Ray.xcuserdatad/UserInterfaceState.xcuserstate


+ 2 - 1
RedAnt ERP Mobile/common/Functions/signature/SignatureViewController.h

@@ -14,7 +14,7 @@
 -(void) SignatureVCReturnImage:(UIImage *)image indexPath :(NSIndexPath*) indexPath;
 -(void) SignatureVCReturnData:(NSData *)imagedata indexPath :(NSIndexPath*) indexPath;
 @end
-@interface SignatureViewController : UIViewController
+@interface SignatureViewController : UIViewController<UITextFieldDelegate>
 //@property (strong, nonatomic) IBOutlet UIView *debugView;
 //@property (strong, nonatomic) IBOutlet SignatureView *signatureView;
 @property (strong, nonatomic)  SignatureView *signatureView;
@@ -23,4 +23,5 @@
 @property (nonatomic, weak) id<SignatureViewControllerDelegate> delegate;
 @property (nonatomic , copy) void (^onReturnImg)(UIImage* img);
 @property CGSize signature_ratio;
+@property int linewidth;
 @end

+ 49 - 11
RedAnt ERP Mobile/common/Functions/signature/SignatureViewController.m

@@ -5,7 +5,7 @@
 //  Created by Ray on 14-8-7.
 //  Copyright (c) 2014年 United Software Applications, Inc. All rights reserved.
 //
-
+#define INTNUMBERS @"0123456789\n"
 #import "SignatureViewController.h"
 //#import "const.h"
 @interface SignatureViewController ()
@@ -32,22 +32,23 @@
     [super viewDidLoad];
     self.navigationItem.title = self.title;
     
-
+    if(self.linewidth==0)
+        self.linewidth=5;
     
-    if(self.signature_ratio.width<=0||self.signature_ratio.height<=0)
+    if(true||self.signature_ratio.width<=0||self.signature_ratio.height<=0)
     {
         self.signatureView= [[SignatureView alloc] initWithFrame:self.view.frame];
     }
     else
     {
+        CGRect rect=CGRectMake(5, 90, self.view.frame.size.width-10, self.view.frame.size.height-95);
         
-        CGSize signatureView_size=CGSizeMake(self.view.frame.size.width, self.view.frame.size.width*self.signature_ratio.height/self.signature_ratio.width);
-        
-        if(signatureView_size.height>self.view.frame.size.height)
-            signatureView_size=CGSizeMake(self.view.frame.size.height*self.signature_ratio.width/self.signature_ratio.height,self.view.frame.size.height);
+        CGSize signatureView_size=CGSizeMake(rect.size.width, rect.size.width*self.signature_ratio.height/self.signature_ratio.width);
         
-        self.signatureView= [[SignatureView alloc] initWithFrame:CGRectMake((self.view.frame.size.width-signatureView_size.width)/2, (self.view.frame.size.height-signatureView_size.height)/2, signatureView_size.width, signatureView_size.height)];
+        if(signatureView_size.height>rect.size.height)
+            signatureView_size=CGSizeMake(rect.size.height*self.signature_ratio.width/self.signature_ratio.height,rect.size.height);
         
+        self.signatureView= [[SignatureView alloc] initWithFrame:CGRectMake((rect.size.width-signatureView_size.width)/2+5, (rect.size.height-signatureView_size.height)/2+90, signatureView_size.width, signatureView_size.height)];
     }
     
     self.signatureView.backgroundColor = [UIColor yellowColor];
@@ -94,7 +95,7 @@
     
 
     
-    [self.signatureView setLineWidth:10.0];
+    [self.signatureView setLineWidth:self.linewidth];
     self.signatureView.foregroundLineColor = [UIColor colorWithRed:0.204 green:0.596 blue:0.859 alpha:1.000];
 //    UIImage* img = [UIImage alloc]initw
     
@@ -134,13 +135,17 @@
     
     
     [alertControl addTextFieldWithConfigurationHandler:^(UITextField *textField) {
-        textField.text = @"5";
+        textField.text = [NSString stringWithFormat:@"%d",self.linewidth];
+        textField.keyboardType=UIKeyboardTypeNumberPad;
+        textField.delegate = self;
         
         
     }];
     
     UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Save" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
-            [self.signatureView setLineWidth:5.0];
+        
+        
+            [self.signatureView setLineWidth:self.linewidth];
 //        UITextField *name = alertControl.textFields.firstObject;
 //        if(name.text.length==0)
 //        {
@@ -203,6 +208,39 @@
     // Dispose of any resources that can be recreated.
 }
 
+
+#pragma mark textField delegate
+-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
+    
+     NSCharacterSet *cs;
+
+        cs = [[NSCharacterSet characterSetWithCharactersInString:INTNUMBERS]invertedSet];
+    
+    NSString *filtered = [[string componentsSeparatedByCharactersInSet:cs]componentsJoinedByString:@""];
+    
+    BOOL canChange = [string isEqualToString:filtered];
+    
+   
+    return canChange;
+}
+- (void)textFieldDidEndEditing:(UITextField *)textField
+{
+    
+    self.linewidth = [textField.text intValue];
+  
+    
+}
+
+//- (void)textFieldDidBeginEditing:(UITextField *)textField
+//{
+//    DebugLog(@"textField shouldChangeCharactersInRange");
+//    
+//    self.lastedit = textField;
+//    UITableViewCell *cell = (UITableViewCell *) textField.superview.superview;
+//    self.lastedit_from  = [self.editorTable indexPathForCell:cell];
+//}
+
+
 /*
 #pragma mark - Navigation
 

+ 26 - 30
RedAnt ERP Mobile/common/Functions/signature/signature.storyboard

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" colorMatched="YES">
     <device id="ipad9_7" orientation="portrait">
         <adaptation id="fullscreen"/>
     </device>
@@ -12,18 +12,17 @@
         <scene sceneID="2S9-GH-6Hr">
             <objects>
                 <viewController storyboardIdentifier="SignatureViewController" title="Signature panel" useStoryboardIdentifierAsRestorationIdentifier="YES" id="nJY-u8-PHN" customClass="SignatureViewController" sceneMemberID="viewController">
-                    <layoutGuides>
-                        <viewControllerLayoutGuide type="top" id="eXi-id-T8f"/>
-                        <viewControllerLayoutGuide type="bottom" id="lEb-cg-6xE"/>
-                    </layoutGuides>
                     <view key="view" contentMode="scaleToFill" id="EWz-QT-t28">
                         <rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                         <subviews>
-                            <imageView hidden="YES" userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="1eC-0c-wj1" customClass="SignatureView">
-                                <rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
-                                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES" flexibleMaxY="YES"/>
-                            </imageView>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Please signature in the yellow area" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="OEo-Ct-kXA">
+                                <rect key="frame" x="238" y="64" width="292" height="21"/>
+                                <autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                <nil key="textColor"/>
+                                <nil key="highlightedColor"/>
+                            </label>
                         </subviews>
                         <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                     </view>
@@ -31,21 +30,17 @@
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="jvi-8Y-CLK" userLabel="First Responder" sceneMemberID="firstResponder"/>
             </objects>
-            <point key="canvasLocation" x="1999" y="-4336"/>
+            <point key="canvasLocation" x="2696" y="-7394"/>
         </scene>
         <!--Title-->
         <scene sceneID="llq-Po-d7N">
             <objects>
                 <viewController storyboardIdentifier="SignatureListViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="xQW-5p-fJu" customClass="SignatureListViewController" sceneMemberID="viewController">
-                    <layoutGuides>
-                        <viewControllerLayoutGuide type="top" id="td7-rJ-h8z"/>
-                        <viewControllerLayoutGuide type="bottom" id="DAa-YE-hAb"/>
-                    </layoutGuides>
                     <view key="view" contentMode="scaleToFill" id="fzZ-IH-jQZ">
                         <rect key="frame" x="0.0" y="0.0" width="376" height="640"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
-                            <tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="p4w-Uo-pFK">
+                            <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="p4w-Uo-pFK">
                                 <rect key="frame" x="0.0" y="0.0" width="376" height="640"/>
                                 <autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
                                 <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
@@ -54,14 +49,14 @@
                                         <rect key="frame" x="0.0" y="28" width="376" height="128"/>
                                         <autoresizingMask key="autoresizingMask" widthSizable="YES"/>
                                         <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="pJ2-Li-nq4" id="hwz-Mn-MnM">
-                                            <rect key="frame" x="0.0" y="0.0" width="376" height="128"/>
+                                            <rect key="frame" x="0.0" y="0.0" width="376" height="127"/>
                                             <autoresizingMask key="autoresizingMask"/>
                                             <subviews>
-                                                <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="5Hk-1I-EQp">
+                                                <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" id="5Hk-1I-EQp">
                                                     <rect key="frame" x="15" y="0.0" width="223" height="128"/>
                                                     <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                                 </imageView>
-                                                <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="npR-Us-Ywj">
+                                                <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="npR-Us-Ywj">
                                                     <rect key="frame" x="303" y="8" width="65" height="30"/>
                                                     <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
                                                     <color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@@ -107,21 +102,17 @@
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="bV8-Sj-hSE" userLabel="First Responder" sceneMemberID="firstResponder"/>
             </objects>
-            <point key="canvasLocation" x="2646.875" y="-4330.078125"/>
+            <point key="canvasLocation" x="3388" y="-7390.0000000000009"/>
         </scene>
         <!--Check Selector View Controller-->
         <scene sceneID="esN-gj-lg0">
             <objects>
                 <viewController storyboardIdentifier="CheckSelectorViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="53f-FJ-cIp" customClass="CheckSelectorViewController" sceneMemberID="viewController">
-                    <layoutGuides>
-                        <viewControllerLayoutGuide type="top" id="MEs-hp-kik"/>
-                        <viewControllerLayoutGuide type="bottom" id="VX5-lc-6ZR"/>
-                    </layoutGuides>
                     <view key="view" contentMode="scaleToFill" id="Wob-uP-qMj">
                         <rect key="frame" x="0.0" y="0.0" width="540" height="620"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
-                            <tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="k8D-US-WZx">
+                            <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="k8D-US-WZx">
                                 <rect key="frame" x="0.0" y="48" width="540" height="526"/>
                                 <autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
                                 <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
@@ -130,18 +121,18 @@
                                         <rect key="frame" x="0.0" y="28" width="540" height="44"/>
                                         <autoresizingMask key="autoresizingMask"/>
                                         <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="9oa-xb-cvi" id="Mqb-XY-jMc">
-                                            <rect key="frame" x="0.0" y="0.0" width="540" height="43.5"/>
+                                            <rect key="frame" x="0.0" y="0.0" width="540" height="43"/>
                                             <autoresizingMask key="autoresizingMask"/>
                                             <subviews>
                                                 <label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="g0z-bw-GId">
-                                                    <rect key="frame" x="15" y="5" width="33.5" height="20.5"/>
+                                                    <rect key="frame" x="15" y="4" width="34" height="21"/>
                                                     <autoresizingMask key="autoresizingMask"/>
                                                     <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                                     <nil key="textColor"/>
                                                     <nil key="highlightedColor"/>
                                                 </label>
                                                 <label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Detail" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="PC3-Mi-xw7">
-                                                    <rect key="frame" x="15" y="25.5" width="33" height="14.5"/>
+                                                    <rect key="frame" x="15" y="25" width="33" height="15"/>
                                                     <autoresizingMask key="autoresizingMask"/>
                                                     <fontDescription key="fontDescription" type="system" pointSize="12"/>
                                                     <nil key="textColor"/>
@@ -156,7 +147,7 @@
                                     <outlet property="delegate" destination="53f-FJ-cIp" id="QgW-Zo-1vd"/>
                                 </connections>
                             </tableView>
-                            <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fUv-0D-vb5">
+                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="fUv-0D-vb5">
                                 <rect key="frame" x="490" y="582" width="30" height="30"/>
                                 <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
                                 <state key="normal" title="OK"/>
@@ -164,7 +155,7 @@
                                     <action selector="OnOKClick:" destination="53f-FJ-cIp" eventType="touchUpInside" id="TXl-ow-jv5"/>
                                 </connections>
                             </button>
-                            <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="W2X-ae-n4Z">
+                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="W2X-ae-n4Z">
                                 <rect key="frame" x="20" y="582" width="48" height="30"/>
                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                                 <state key="normal" title="Cancel"/>
@@ -182,7 +173,12 @@
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="8Dt-jM-eNm" userLabel="First Responder" sceneMemberID="firstResponder"/>
             </objects>
-            <point key="canvasLocation" x="3187.5" y="-4331.8359375"/>
+            <point key="canvasLocation" x="4080" y="-7393.0000000000009"/>
         </scene>
     </scenes>
+    <simulatedMetricsContainer key="defaultSimulatedMetrics">
+        <simulatedStatusBarMetrics key="statusBar"/>
+        <simulatedOrientationMetrics key="orientation"/>
+        <simulatedScreenMetrics key="destination"/>
+    </simulatedMetricsContainer>
 </document>