Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
X
xffruit
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张杰
xffruit
Commits
5db190e9
Commit
5db190e9
authored
8 years ago
by
Sandy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
包装规格限制输入小数位数
parent
c63ff51b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
1 deletion
+50
-1
Info.plist
XFFruit/Info.plist
+1
-1
ShopDetaileViewController.m
...trollers/PurchaseNotice/Views/ShopDetaileViewController.m
+49
-0
No files found.
XFFruit/Info.plist
View file @
5db190e9
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
<
k
e
y
>
CFBundlePackageType
<
/k
e
y
>
<
k
e
y
>
CFBundlePackageType
<
/k
e
y
>
<
string
>
APPL
<
/string
>
<
string
>
APPL
<
/string
>
<
k
e
y
>
CFBundleShortVersionString
<
/k
e
y
>
<
k
e
y
>
CFBundleShortVersionString
<
/k
e
y
>
<
string
>
1.2.
8
<
/string
>
<
string
>
1.2.
9
<
/string
>
<
k
e
y
>
CFBundleSignature
<
/k
e
y
>
<
k
e
y
>
CFBundleSignature
<
/k
e
y
>
<
string
>
????
<
/string
>
<
string
>
????
<
/string
>
<
k
e
y
>
CFBundleVersion
<
/k
e
y
>
<
k
e
y
>
CFBundleVersion
<
/k
e
y
>
...
...
This diff is collapsed.
Click to expand it.
XFFruit/ViewControllers/PurchaseNotice/Views/ShopDetaileViewController.m
View file @
5db190e9
...
@@ -363,6 +363,7 @@ typedef enum : NSUInteger {
...
@@ -363,6 +363,7 @@ typedef enum : NSUInteger {
label
.
left
=
textField
.
right
+
5
;
label
.
left
=
textField
.
right
+
5
;
_measureUnitLabel
=
label
;
_measureUnitLabel
=
label
;
textField
.
placeholder
=
@"输入包装规格"
;
textField
.
placeholder
=
@"输入包装规格"
;
textField
.
tag
=
111
;
[
textField
addTarget
:
self
action
:
@selector
(
textChange
:
)
forControlEvents
:
UIControlEventAllEditingEvents
];
[
textField
addTarget
:
self
action
:
@selector
(
textChange
:
)
forControlEvents
:
UIControlEventAllEditingEvents
];
packageSpecification
=
textField
;
//包装规格
packageSpecification
=
textField
;
//包装规格
...
@@ -455,6 +456,54 @@ typedef enum : NSUInteger {
...
@@ -455,6 +456,54 @@ typedef enum : NSUInteger {
}
}
}
}
-
(
BOOL
)
textField
:
(
UITextField
*
)
textField
shouldChangeCharactersInRange
:
(
NSRange
)
range
replacementString
:
(
NSString
*
)
string
{
if
(
textField
.
tag
!=
111
)
{
return
YES
;
}
NSMutableString
*
futureString
=
[
NSMutableString
stringWithString
:
textField
.
text
];
// kLOG(@"%@", futureString);
[
futureString
insertString
:
string
atIndex
:
range
.
location
];
// kLOG(@"----%@", futureString);
NSInteger
flag
=
0
;
NSInteger
pointNum
=
0
;
//用于标记小数点的数量,只能有一个小数点
const
NSInteger
limited
=
2
;
//限制小数点后面的位数
for
(
int
i
=
(
int
)
futureString
.
length
-
1
;
i
>=
0
;
i
--
)
{
if
([
futureString
characterAtIndex
:
i
]
==
'.'
)
{
pointNum
++
;
// kLOG(@"----->>>%ld",pointNum);
if
(
pointNum
==
2
)
{
return
NO
;
}
}
}
for
(
int
i
=
(
int
)
futureString
.
length
-
1
;
i
>=
0
;
i
--
)
{
if
([
futureString
characterAtIndex
:
i
]
==
'.'
)
{
if
(
flag
>
limited
)
{
return
NO
;
}
break
;
}
flag
++
;
}
return
YES
;
}
#pragma mark - textFiled事件
#pragma mark - textFiled事件
-
(
void
)
textChange
:
(
UITextField
*
)
textField
{
-
(
void
)
textChange
:
(
UITextField
*
)
textField
{
//包装规格和包装数量
//包装规格和包装数量
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment