Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
contactos-app
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Javier Heisecke
contactos-app
Commits
4c4ec645
Commit
4c4ec645
authored
Mar 27, 2020
by
Javier Heisekce
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mostramos números correctamente
parent
ef27a35c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
27 deletions
+90
-27
ContactsApp/Base.lproj/Main.storyboard
+68
-18
ContactsApp/ContactsViewController.swift
+1
-4
ContactsApp/SingleContactViewController.swift
+21
-5
No files found.
ContactsApp/Base.lproj/Main.storyboard
View file @
4c4ec645
...
@@ -62,40 +62,90 @@
...
@@ -62,40 +62,90 @@
<autoresizingMask
key=
"autoresizingMask"
widthSizable=
"YES"
heightSizable=
"YES"
/>
<autoresizingMask
key=
"autoresizingMask"
widthSizable=
"YES"
heightSizable=
"YES"
/>
<subviews>
<subviews>
<imageView
clipsSubviews=
"YES"
userInteractionEnabled=
"NO"
contentMode=
"scaleAspectFit"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"SSh-qK-Te0"
>
<imageView
clipsSubviews=
"YES"
userInteractionEnabled=
"NO"
contentMode=
"scaleAspectFit"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"SSh-qK-Te0"
>
<rect
key=
"frame"
x=
"1
6"
y=
"73
"
width=
"100"
height=
"100"
/>
<rect
key=
"frame"
x=
"1
37"
y=
"69
"
width=
"100"
height=
"100"
/>
<constraints>
<constraints>
<constraint
firstAttribute=
"height"
constant=
"100"
id=
"
GFa-s9-VDx
"
/>
<constraint
firstAttribute=
"height"
constant=
"100"
id=
"
n9x-Ru-z25
"
/>
<constraint
firstAttribute=
"width"
constant=
"100"
id=
"
zm3-wz-QlG
"
/>
<constraint
firstAttribute=
"width"
constant=
"100"
id=
"
nPy-0W-mhe
"
/>
</constraints>
</constraints>
</imageView>
</imageView>
<label
opaque=
"NO"
userInteractionEnabled=
"NO"
contentMode=
"left"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
text=
"KATE FODSFUBSDIFUBSD"
textAlignment=
"natural"
lineBreakMode=
"tailTruncation"
numberOfLines=
"0"
baselineAdjustment=
"alignBaselines"
adjustsFontSizeToFit=
"NO"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"1Kw-mC-GdR"
>
<label
opaque=
"NO"
userInteractionEnabled=
"NO"
contentMode=
"left"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
text=
"KATE FODSFUBSDIFUBSD"
textAlignment=
"center"
lineBreakMode=
"tailTruncation"
numberOfLines=
"0"
baselineAdjustment=
"alignBaselines"
adjustsFontSizeToFit=
"NO"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"1Kw-mC-GdR"
>
<rect
key=
"frame"
x=
"124"
y=
"70"
width=
"236.5"
height=
"24"
/>
<rect
key=
"frame"
x=
"58"
y=
"177"
width=
"259"
height=
"27"
/>
<fontDescription
key=
"fontDescription"
style=
"UICTFontTextStyleTitle3"
/>
<constraints>
<constraint
firstAttribute=
"height"
constant=
"27"
id=
"4T0-IY-YZ1"
/>
</constraints>
<fontDescription
key=
"fontDescription"
style=
"UICTFontTextStyleTitle2"
/>
<nil
key=
"textColor"
/>
<nil
key=
"highlightedColor"
/>
</label>
<button
opaque=
"NO"
contentMode=
"scaleToFill"
contentHorizontalAlignment=
"center"
contentVerticalAlignment=
"center"
buttonType=
"roundedRect"
lineBreakMode=
"middleTruncation"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"eBo-CT-x9g"
>
<rect
key=
"frame"
x=
"58"
y=
"212"
width=
"30"
height=
"30"
/>
<state
key=
"normal"
title=
"Call"
/>
<connections>
<action
selector=
"callButton:"
destination=
"i2T-MY-6qf"
eventType=
"touchUpInside"
id=
"nXp-Mk-RCH"
/>
</connections>
</button>
<label
hidden=
"YES"
opaque=
"NO"
userInteractionEnabled=
"NO"
contentMode=
"left"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
text=
"mobile"
textAlignment=
"natural"
lineBreakMode=
"tailTruncation"
baselineAdjustment=
"alignBaselines"
adjustsFontSizeToFit=
"NO"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"KxJ-Qv-kA7"
>
<rect
key=
"frame"
x=
"16"
y=
"240"
width=
"44"
height=
"17"
/>
<fontDescription
key=
"fontDescription"
type=
"system"
pointSize=
"14"
/>
<nil
key=
"textColor"
/>
<nil
key=
"textColor"
/>
<nil
key=
"highlightedColor"
/>
<nil
key=
"highlightedColor"
/>
</label>
</label>
<label
opaque=
"NO"
userInteractionEnabled=
"NO"
contentMode=
"left"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
text=
"Label"
textAlignment=
"natural"
lineBreakMode=
"tailTruncation"
baselineAdjustment=
"alignBaselines"
adjustsFontSizeToFit=
"NO"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"6Eu-n5-bWt"
>
<button
hidden=
"YES"
opaque=
"NO"
contentMode=
"scaleToFill"
contentHorizontalAlignment=
"center"
contentVerticalAlignment=
"center"
buttonType=
"roundedRect"
lineBreakMode=
"middleTruncation"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"m4m-IH-dYv"
>
<rect
key=
"frame"
x=
"124"
y=
"113"
width=
"48"
height=
"24"
/>
<rect
key=
"frame"
x=
"16"
y=
"259"
width=
"111"
height=
"30"
/>
<fontDescription
key=
"fontDescription"
style=
"UICTFontTextStyleTitle3"
/>
<state
key=
"normal"
title=
"(888) 555-5512"
/>
<color
key=
"textColor"
systemColor=
"systemBlueColor"
red=
"0.0"
green=
"0.47843137250000001"
blue=
"1"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"sRGB"
/>
<connections>
<action
selector=
"callButton:"
destination=
"i2T-MY-6qf"
eventType=
"touchUpInside"
id=
"H4b-52-ngQ"
/>
</connections>
</button>
<label
hidden=
"YES"
opaque=
"NO"
userInteractionEnabled=
"NO"
contentMode=
"left"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
text=
"mobile"
textAlignment=
"natural"
lineBreakMode=
"tailTruncation"
baselineAdjustment=
"alignBaselines"
adjustsFontSizeToFit=
"NO"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"vQF-Eq-KWL"
>
<rect
key=
"frame"
x=
"18"
y=
"297"
width=
"44"
height=
"17"
/>
<fontDescription
key=
"fontDescription"
type=
"system"
pointSize=
"14"
/>
<nil
key=
"textColor"
/>
<nil
key=
"highlightedColor"
/>
<nil
key=
"highlightedColor"
/>
</label>
</label>
<button
hidden=
"YES"
opaque=
"NO"
contentMode=
"scaleToFill"
contentHorizontalAlignment=
"center"
contentVerticalAlignment=
"center"
buttonType=
"roundedRect"
lineBreakMode=
"middleTruncation"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"78U-Dh-WFs"
>
<rect
key=
"frame"
x=
"18"
y=
"316"
width=
"111"
height=
"30"
/>
<state
key=
"normal"
title=
"(888) 555-5512"
/>
<connections>
<action
selector=
"callButton:"
destination=
"i2T-MY-6qf"
eventType=
"touchUpInside"
id=
"xgn-e5-2aF"
/>
</connections>
</button>
</subviews>
</subviews>
<color
key=
"backgroundColor"
systemColor=
"systemBackgroundColor"
cocoaTouchSystemColor=
"whiteColor"
/>
<color
key=
"backgroundColor"
systemColor=
"systemBackgroundColor"
cocoaTouchSystemColor=
"whiteColor"
/>
<constraints>
<constraints>
<constraint
firstItem=
"6Eu-n5-bWt"
firstAttribute=
"leading"
secondItem=
"SSh-qK-Te0"
secondAttribute=
"trailing"
constant=
"8"
id=
"KY6-oD-zqi"
/>
<constraint
firstItem=
"YV1-WY-lTn"
firstAttribute=
"trailing"
relation=
"greaterThanOrEqual"
secondItem=
"m4m-IH-dYv"
secondAttribute=
"trailing"
symbolic=
"YES"
id=
"1AC-tb-Lsi"
/>
<constraint
firstItem=
"1Kw-mC-GdR"
firstAttribute=
"leading"
secondItem=
"SSh-qK-Te0"
secondAttribute=
"trailing"
constant=
"8"
id=
"Ogd-VN-JDE"
/>
<constraint
firstItem=
"SSh-qK-Te0"
firstAttribute=
"leading"
secondItem=
"YV1-WY-lTn"
secondAttribute=
"leading"
constant=
"137"
id=
"5ra-OQ-OXE"
/>
<constraint
firstItem=
"1Kw-mC-GdR"
firstAttribute=
"top"
secondItem=
"YV1-WY-lTn"
secondAttribute=
"top"
constant=
"26"
id=
"YZK-KY-6DD"
/>
<constraint
firstItem=
"78U-Dh-WFs"
firstAttribute=
"top"
secondItem=
"vQF-Eq-KWL"
secondAttribute=
"bottom"
constant=
"2"
id=
"7Qu-oy-WiY"
/>
<constraint
firstItem=
"6Eu-n5-bWt"
firstAttribute=
"top"
secondItem=
"1Kw-mC-GdR"
secondAttribute=
"bottom"
constant=
"19"
id=
"YuN-VJ-nj8"
/>
<constraint
firstItem=
"KxJ-Qv-kA7"
firstAttribute=
"top"
secondItem=
"eBo-CT-x9g"
secondAttribute=
"bottom"
constant=
"-2"
id=
"AbZ-R1-uip"
/>
<constraint
firstItem=
"SSh-qK-Te0"
firstAttribute=
"top"
secondItem=
"1Kw-mC-GdR"
secondAttribute=
"bottom"
constant=
"-21"
id=
"a1j-Kp-lBQ"
/>
<constraint
firstItem=
"eBo-CT-x9g"
firstAttribute=
"top"
secondItem=
"1Kw-mC-GdR"
secondAttribute=
"bottom"
constant=
"8"
id=
"AqY-Nn-a6x"
/>
<constraint
firstItem=
"SSh-qK-Te0"
firstAttribute=
"leading"
secondItem=
"T9g-Qz-Xx3"
secondAttribute=
"leadingMargin"
id=
"z7n-CK-Jte"
/>
<constraint
firstItem=
"vQF-Eq-KWL"
firstAttribute=
"leading"
secondItem=
"YV1-WY-lTn"
secondAttribute=
"leading"
constant=
"18"
id=
"I0k-GE-QJ0"
/>
<constraint
firstItem=
"YV1-WY-lTn"
firstAttribute=
"trailing"
relation=
"greaterThanOrEqual"
secondItem=
"78U-Dh-WFs"
secondAttribute=
"trailing"
symbolic=
"YES"
id=
"KQY-U5-hvm"
/>
<constraint
firstItem=
"1Kw-mC-GdR"
firstAttribute=
"top"
secondItem=
"SSh-qK-Te0"
secondAttribute=
"bottom"
constant=
"8"
id=
"Ktz-1f-c23"
/>
<constraint
firstItem=
"m4m-IH-dYv"
firstAttribute=
"leading"
secondItem=
"YV1-WY-lTn"
secondAttribute=
"leading"
constant=
"16"
id=
"Ky9-D3-Q8g"
/>
<constraint
firstItem=
"vQF-Eq-KWL"
firstAttribute=
"top"
secondItem=
"m4m-IH-dYv"
secondAttribute=
"bottom"
constant=
"8"
id=
"NnL-pe-PyE"
/>
<constraint
firstItem=
"eBo-CT-x9g"
firstAttribute=
"leading"
secondItem=
"1Kw-mC-GdR"
secondAttribute=
"leading"
id=
"P95-3L-FTz"
/>
<constraint
firstItem=
"YV1-WY-lTn"
firstAttribute=
"trailing"
relation=
"greaterThanOrEqual"
secondItem=
"eBo-CT-x9g"
secondAttribute=
"trailing"
symbolic=
"YES"
id=
"S0r-tt-H4L"
/>
<constraint
firstItem=
"YV1-WY-lTn"
firstAttribute=
"trailing"
secondItem=
"SSh-qK-Te0"
secondAttribute=
"trailing"
constant=
"138"
id=
"SoA-lc-Ayp"
/>
<constraint
firstItem=
"m4m-IH-dYv"
firstAttribute=
"top"
secondItem=
"KxJ-Qv-kA7"
secondAttribute=
"bottom"
constant=
"2"
id=
"cXc-j4-79C"
/>
<constraint
firstItem=
"78U-Dh-WFs"
firstAttribute=
"leading"
secondItem=
"YV1-WY-lTn"
secondAttribute=
"leading"
constant=
"18"
id=
"cc2-xi-9qt"
/>
<constraint
firstItem=
"1Kw-mC-GdR"
firstAttribute=
"leading"
secondItem=
"YV1-WY-lTn"
secondAttribute=
"leading"
constant=
"58"
id=
"epS-Yc-0NF"
/>
<constraint
firstItem=
"SSh-qK-Te0"
firstAttribute=
"top"
secondItem=
"YV1-WY-lTn"
secondAttribute=
"top"
constant=
"25"
id=
"jxI-6w-TU6"
/>
<constraint
firstItem=
"YV1-WY-lTn"
firstAttribute=
"trailing"
relation=
"greaterThanOrEqual"
secondItem=
"vQF-Eq-KWL"
secondAttribute=
"trailing"
symbolic=
"YES"
id=
"nUf-po-YIk"
/>
<constraint
firstItem=
"YV1-WY-lTn"
firstAttribute=
"trailing"
relation=
"greaterThanOrEqual"
secondItem=
"KxJ-Qv-kA7"
secondAttribute=
"trailing"
symbolic=
"YES"
id=
"rJB-y4-kit"
/>
<constraint
firstItem=
"YV1-WY-lTn"
firstAttribute=
"trailing"
secondItem=
"1Kw-mC-GdR"
secondAttribute=
"trailing"
constant=
"58"
id=
"rtf-K6-ZTK"
/>
<constraint
firstItem=
"KxJ-Qv-kA7"
firstAttribute=
"leading"
secondItem=
"YV1-WY-lTn"
secondAttribute=
"leading"
constant=
"16"
id=
"zOD-Bq-oI1"
/>
</constraints>
</constraints>
<viewLayoutGuide
key=
"safeArea"
id=
"YV1-WY-lTn"
/>
<viewLayoutGuide
key=
"safeArea"
id=
"YV1-WY-lTn"
/>
</view>
</view>
<navigationItem
key=
"navigationItem"
id=
"y8U-qe-KjJ"
/>
<navigationItem
key=
"navigationItem"
id=
"y8U-qe-KjJ"
>
<barButtonItem
key=
"backBarButtonItem"
title=
"Contacts"
id=
"4iP-Za-MPC"
/>
</navigationItem>
<connections>
<connections>
<outlet
property=
"contactFullname"
destination=
"1Kw-mC-GdR"
id=
"p01-Rh-EGg"
/>
<outlet
property=
"contactFullname"
destination=
"1Kw-mC-GdR"
id=
"p01-Rh-EGg"
/>
<outlet
property=
"phoneNumber"
destination=
"6Eu-n5-bWt"
id=
"T4T-Ts-Lbq"
/>
<outlet
property=
"otherPhoneLabel"
destination=
"vQF-Eq-KWL"
id=
"6bS-Cs-Wse"
/>
<outlet
property=
"otherPhoneNumber"
destination=
"78U-Dh-WFs"
id=
"3oC-ap-6pF"
/>
<outlet
property=
"phoneLabel"
destination=
"KxJ-Qv-kA7"
id=
"fjD-LM-At1"
/>
<outlet
property=
"phoneNumber"
destination=
"m4m-IH-dYv"
id=
"Ilr-VL-oU5"
/>
<outlet
property=
"profilePic"
destination=
"SSh-qK-Te0"
id=
"raT-yr-aQm"
/>
<outlet
property=
"profilePic"
destination=
"SSh-qK-Te0"
id=
"raT-yr-aQm"
/>
</connections>
</connections>
</viewController>
</viewController>
...
...
ContactsApp/ContactsViewController.swift
View file @
4c4ec645
...
@@ -25,7 +25,7 @@ class ContactsViewController: UIViewController {
...
@@ -25,7 +25,7 @@ class ContactsViewController: UIViewController {
func
importContacts
()
{
func
importContacts
()
{
let
keys
=
[
CNContactFormatter
.
descriptorForRequiredKeys
(
for
:
.
fullName
),
CNContactEmailAddressesKey
,
CNContactPhoneNumbersKey
,
CNContactImageDataKey
,
CNContactImageDataAvailableKey
]
as
[
Any
]
let
keys
=
[
CNContactFormatter
.
descriptorForRequiredKeys
(
for
:
.
fullName
),
CNContactEmailAddressesKey
,
CNContactPhoneNumbersKey
,
CNContactImageDataKey
]
as
[
Any
]
let
request
=
CNContactFetchRequest
(
keysToFetch
:
keys
as!
[
CNKeyDescriptor
])
let
request
=
CNContactFetchRequest
(
keysToFetch
:
keys
as!
[
CNKeyDescriptor
])
request
.
sortOrder
=
CNContactSortOrder
.
givenName
request
.
sortOrder
=
CNContactSortOrder
.
givenName
do
{
do
{
...
@@ -52,9 +52,6 @@ class ContactsViewController: UIViewController {
...
@@ -52,9 +52,6 @@ class ContactsViewController: UIViewController {
}
}
}
}
self
.
contactStructArray
.
append
(
ContactStruct
(
isExpanded
:
true
,
contacts
:
contacts
,
letter
:
auxLetter
))
//agregamos el ultimo nombre
self
.
contactStructArray
.
append
(
ContactStruct
(
isExpanded
:
true
,
contacts
:
contacts
,
letter
:
auxLetter
))
//agregamos el ultimo nombre
print
(
"CONTACTOS ORDENADOS"
)
print
(
self
.
contactStructArray
)
print
(
"======================"
)
}
}
catch
{
catch
{
print
(
"unable to fetch contacts"
)
print
(
"unable to fetch contacts"
)
...
...
ContactsApp/SingleContactViewController.swift
View file @
4c4ec645
...
@@ -14,24 +14,40 @@ class SingleContactViewController: UIViewController {
...
@@ -14,24 +14,40 @@ class SingleContactViewController: UIViewController {
@IBOutlet
weak
var
contactFullname
:
UILabel
!
@IBOutlet
weak
var
contactFullname
:
UILabel
!
var
selectedContact
:
CNContact
?
var
selectedContact
:
CNContact
?
@IBOutlet
weak
var
profilePic
:
UIImageView
!
@IBOutlet
weak
var
profilePic
:
UIImageView
!
@IBOutlet
weak
var
phoneNumber
:
UILabel
!
@IBOutlet
weak
var
phoneNumber
:
UIButton
!
@IBOutlet
weak
var
otherPhoneNumber
:
UIButton
!
@IBOutlet
weak
var
otherPhoneLabel
:
UILabel
!
@IBOutlet
weak
var
phoneLabel
:
UILabel
!
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
if
let
contact
=
selectedContact
{
if
let
contact
=
selectedContact
{
title
=
"
\(
contact
.
givenName
)
\(
contact
.
familyName
)
"
title
=
"
\(
contact
.
givenName
)
\(
contact
.
familyName
)
"
contactFullname
.
text
=
"
\(
contact
.
givenName
)
\(
contact
.
familyName
)
"
contactFullname
.
text
=
"
\(
contact
.
givenName
)
\(
contact
.
familyName
)
"
//phoneNumber.text = CNLabeledValue.localizedStringForLabel(contact.phoneNumbers)
if
let
phones
=
contact
.
phoneNumbers
.
first
{
let
phoneTitle
:
String
=
CNLabeledValue
<
NSString
>.
localizedString
(
forLabel
:
phones
.
label
!
)
if
contact
.
imageDataAvailable
{
phoneLabel
.
text
=
phoneTitle
phoneNumber
.
setTitle
(
phones
.
value
.
stringValue
,
for
:
.
normal
)
phoneLabel
.
isHidden
=
false
phoneNumber
.
isHidden
=
false
}
if
contact
.
phoneNumbers
.
last
!=
contact
.
phoneNumbers
.
first
,
let
phones
=
contact
.
phoneNumbers
.
last
{
let
phoneTitle
:
String
=
CNLabeledValue
<
NSString
>.
localizedString
(
forLabel
:
phones
.
label
!
)
otherPhoneLabel
.
text
=
phoneTitle
otherPhoneNumber
.
setTitle
(
phones
.
value
.
stringValue
,
for
:
.
normal
)
otherPhoneLabel
.
isHidden
=
false
otherPhoneNumber
.
isHidden
=
false
}
if
let
image
=
contact
.
imageData
{
if
let
image
=
contact
.
imageData
{
profilePic
.
layer
.
cornerRadius
=
profilePic
.
frame
.
height
/
2
if
let
imageData
=
UIImage
(
data
:
image
){
if
let
imageData
=
UIImage
(
data
:
image
){
profilePic
.
image
=
imageData
profilePic
.
image
=
imageData
}
}
}
}
}
}
}
}
@IBAction
func
callButton
(
_
sender
:
Any
)
{
}
}
}
}
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