CNLabelPhoneNumber Label Picker
I've been looking for a solution on this for a while now and can't find a thing on implementing this (screenshot provided below).
I'm creating a custom ContactsViewController
which uses the CNContact
framework for CRUD functionalities. All is clear on how to implement them, aside from choosing a phone number label. Is there such a thing as a picker view controller for this or should I implement it manually?
ios objective-c cncontact
add a comment |
I've been looking for a solution on this for a while now and can't find a thing on implementing this (screenshot provided below).
I'm creating a custom ContactsViewController
which uses the CNContact
framework for CRUD functionalities. All is clear on how to implement them, aside from choosing a phone number label. Is there such a thing as a picker view controller for this or should I implement it manually?
ios objective-c cncontact
@TamásSengel yup, I was thinking this way too, was just wondering if there a list of labels to get from including the Custom Label part if ever the user adds one.
– Lysdexia
Nov 26 '18 at 1:02
add a comment |
I've been looking for a solution on this for a while now and can't find a thing on implementing this (screenshot provided below).
I'm creating a custom ContactsViewController
which uses the CNContact
framework for CRUD functionalities. All is clear on how to implement them, aside from choosing a phone number label. Is there such a thing as a picker view controller for this or should I implement it manually?
ios objective-c cncontact
I've been looking for a solution on this for a while now and can't find a thing on implementing this (screenshot provided below).
I'm creating a custom ContactsViewController
which uses the CNContact
framework for CRUD functionalities. All is clear on how to implement them, aside from choosing a phone number label. Is there such a thing as a picker view controller for this or should I implement it manually?
ios objective-c cncontact
ios objective-c cncontact
edited Nov 26 '18 at 2:33
Tamás Sengel
26.4k146793
26.4k146793
asked Nov 23 '18 at 7:49
Lysdexia
189418
189418
@TamásSengel yup, I was thinking this way too, was just wondering if there a list of labels to get from including the Custom Label part if ever the user adds one.
– Lysdexia
Nov 26 '18 at 1:02
add a comment |
@TamásSengel yup, I was thinking this way too, was just wondering if there a list of labels to get from including the Custom Label part if ever the user adds one.
– Lysdexia
Nov 26 '18 at 1:02
@TamásSengel yup, I was thinking this way too, was just wondering if there a list of labels to get from including the Custom Label part if ever the user adds one.
– Lysdexia
Nov 26 '18 at 1:02
@TamásSengel yup, I was thinking this way too, was just wondering if there a list of labels to get from including the Custom Label part if ever the user adds one.
– Lysdexia
Nov 26 '18 at 1:02
add a comment |
1 Answer
1
active
oldest
votes
You should implement that screen manually. The screen on your screenshot is a UITableViewController
with a grouped UITableView
and a checkmark accessory indicator for the selected cell.
Here is the list for predefined phone number labels (from the Apple Developer Documentation):
╔════════════════════════════╦═════════════════════╗
║ String ║ Description ║
╠════════════════════════════╬═════════════════════╣
║ CNLabelHome ║ Home label ║
║ CNLabelWork ║ Work label ║
║ CNLabelPhoneNumberiPhone ║ iPhone number ║
║ CNLabelPhoneNumberMobile ║ Mobile phone number ║
║ CNLabelPhoneNumberMain ║ Main phone number ║
║ CNLabelPhoneNumberHomeFax ║ Home fax number ║
║ CNLabelPhoneNumberWorkFax ║ Work fax number ║
║ CNLabelPhoneNumberOtherFax ║ Other fax number ║
║ CNLabelPhoneNumberPager ║ Pager phone number ║
╚════════════════════════════╩═════════════════════╝
To display the localized names of these constants, use CNLabeledValue.localizedString(forLabel:)
(thanks, OOPer):
Swift
let localizedLabelString = CNLabeledValue<NSString>.localizedString(forLabel: CNLabelPhoneNumberiPhone)
print(localizedLabelString) //iPhone
Objective-C
NSString *localizedLabelString = [CNLabeledValue localizedStringForLabel: CNLabelPhoneNumberiPhone];
NSLog(@"%@", localizedLabelString); //iPhone
If you want to create a custom label for a contact, just use an arbitrary string for the label's name:
let phoneNumber = CNPhoneNumber(stringValue: "+18001234567")
let labeledPhoneNumber = CNLabeledValue(label: "arbitrary string", value: phoneNumber)
contact.phoneNumbers.append(labeledPhoneNumber)
Thanks! This should work, but a follow-up question. How about those labels that added as a custom?
– Lysdexia
Nov 26 '18 at 3:01
@Lysdexia If the label's string value is not in the list of predefined constants, then it's a custom label.
– Tamás Sengel
Nov 26 '18 at 3:04
1
Thanks! I've accepted your answer, but a follow-up question. How can I manage the custom labels? Also, the iOS Contacts app has a label of "home", on the documentation it doesn't have it. Do you have any idea?
– Lysdexia
Nov 26 '18 at 9:14
@Lysdexia I added home and work labels to the table, thank you for mentioning this! Also, I've added a section about custom labels to the end.
– Tamás Sengel
Nov 26 '18 at 16:45
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53442582%2fcnlabelphonenumber-label-picker%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You should implement that screen manually. The screen on your screenshot is a UITableViewController
with a grouped UITableView
and a checkmark accessory indicator for the selected cell.
Here is the list for predefined phone number labels (from the Apple Developer Documentation):
╔════════════════════════════╦═════════════════════╗
║ String ║ Description ║
╠════════════════════════════╬═════════════════════╣
║ CNLabelHome ║ Home label ║
║ CNLabelWork ║ Work label ║
║ CNLabelPhoneNumberiPhone ║ iPhone number ║
║ CNLabelPhoneNumberMobile ║ Mobile phone number ║
║ CNLabelPhoneNumberMain ║ Main phone number ║
║ CNLabelPhoneNumberHomeFax ║ Home fax number ║
║ CNLabelPhoneNumberWorkFax ║ Work fax number ║
║ CNLabelPhoneNumberOtherFax ║ Other fax number ║
║ CNLabelPhoneNumberPager ║ Pager phone number ║
╚════════════════════════════╩═════════════════════╝
To display the localized names of these constants, use CNLabeledValue.localizedString(forLabel:)
(thanks, OOPer):
Swift
let localizedLabelString = CNLabeledValue<NSString>.localizedString(forLabel: CNLabelPhoneNumberiPhone)
print(localizedLabelString) //iPhone
Objective-C
NSString *localizedLabelString = [CNLabeledValue localizedStringForLabel: CNLabelPhoneNumberiPhone];
NSLog(@"%@", localizedLabelString); //iPhone
If you want to create a custom label for a contact, just use an arbitrary string for the label's name:
let phoneNumber = CNPhoneNumber(stringValue: "+18001234567")
let labeledPhoneNumber = CNLabeledValue(label: "arbitrary string", value: phoneNumber)
contact.phoneNumbers.append(labeledPhoneNumber)
Thanks! This should work, but a follow-up question. How about those labels that added as a custom?
– Lysdexia
Nov 26 '18 at 3:01
@Lysdexia If the label's string value is not in the list of predefined constants, then it's a custom label.
– Tamás Sengel
Nov 26 '18 at 3:04
1
Thanks! I've accepted your answer, but a follow-up question. How can I manage the custom labels? Also, the iOS Contacts app has a label of "home", on the documentation it doesn't have it. Do you have any idea?
– Lysdexia
Nov 26 '18 at 9:14
@Lysdexia I added home and work labels to the table, thank you for mentioning this! Also, I've added a section about custom labels to the end.
– Tamás Sengel
Nov 26 '18 at 16:45
add a comment |
You should implement that screen manually. The screen on your screenshot is a UITableViewController
with a grouped UITableView
and a checkmark accessory indicator for the selected cell.
Here is the list for predefined phone number labels (from the Apple Developer Documentation):
╔════════════════════════════╦═════════════════════╗
║ String ║ Description ║
╠════════════════════════════╬═════════════════════╣
║ CNLabelHome ║ Home label ║
║ CNLabelWork ║ Work label ║
║ CNLabelPhoneNumberiPhone ║ iPhone number ║
║ CNLabelPhoneNumberMobile ║ Mobile phone number ║
║ CNLabelPhoneNumberMain ║ Main phone number ║
║ CNLabelPhoneNumberHomeFax ║ Home fax number ║
║ CNLabelPhoneNumberWorkFax ║ Work fax number ║
║ CNLabelPhoneNumberOtherFax ║ Other fax number ║
║ CNLabelPhoneNumberPager ║ Pager phone number ║
╚════════════════════════════╩═════════════════════╝
To display the localized names of these constants, use CNLabeledValue.localizedString(forLabel:)
(thanks, OOPer):
Swift
let localizedLabelString = CNLabeledValue<NSString>.localizedString(forLabel: CNLabelPhoneNumberiPhone)
print(localizedLabelString) //iPhone
Objective-C
NSString *localizedLabelString = [CNLabeledValue localizedStringForLabel: CNLabelPhoneNumberiPhone];
NSLog(@"%@", localizedLabelString); //iPhone
If you want to create a custom label for a contact, just use an arbitrary string for the label's name:
let phoneNumber = CNPhoneNumber(stringValue: "+18001234567")
let labeledPhoneNumber = CNLabeledValue(label: "arbitrary string", value: phoneNumber)
contact.phoneNumbers.append(labeledPhoneNumber)
Thanks! This should work, but a follow-up question. How about those labels that added as a custom?
– Lysdexia
Nov 26 '18 at 3:01
@Lysdexia If the label's string value is not in the list of predefined constants, then it's a custom label.
– Tamás Sengel
Nov 26 '18 at 3:04
1
Thanks! I've accepted your answer, but a follow-up question. How can I manage the custom labels? Also, the iOS Contacts app has a label of "home", on the documentation it doesn't have it. Do you have any idea?
– Lysdexia
Nov 26 '18 at 9:14
@Lysdexia I added home and work labels to the table, thank you for mentioning this! Also, I've added a section about custom labels to the end.
– Tamás Sengel
Nov 26 '18 at 16:45
add a comment |
You should implement that screen manually. The screen on your screenshot is a UITableViewController
with a grouped UITableView
and a checkmark accessory indicator for the selected cell.
Here is the list for predefined phone number labels (from the Apple Developer Documentation):
╔════════════════════════════╦═════════════════════╗
║ String ║ Description ║
╠════════════════════════════╬═════════════════════╣
║ CNLabelHome ║ Home label ║
║ CNLabelWork ║ Work label ║
║ CNLabelPhoneNumberiPhone ║ iPhone number ║
║ CNLabelPhoneNumberMobile ║ Mobile phone number ║
║ CNLabelPhoneNumberMain ║ Main phone number ║
║ CNLabelPhoneNumberHomeFax ║ Home fax number ║
║ CNLabelPhoneNumberWorkFax ║ Work fax number ║
║ CNLabelPhoneNumberOtherFax ║ Other fax number ║
║ CNLabelPhoneNumberPager ║ Pager phone number ║
╚════════════════════════════╩═════════════════════╝
To display the localized names of these constants, use CNLabeledValue.localizedString(forLabel:)
(thanks, OOPer):
Swift
let localizedLabelString = CNLabeledValue<NSString>.localizedString(forLabel: CNLabelPhoneNumberiPhone)
print(localizedLabelString) //iPhone
Objective-C
NSString *localizedLabelString = [CNLabeledValue localizedStringForLabel: CNLabelPhoneNumberiPhone];
NSLog(@"%@", localizedLabelString); //iPhone
If you want to create a custom label for a contact, just use an arbitrary string for the label's name:
let phoneNumber = CNPhoneNumber(stringValue: "+18001234567")
let labeledPhoneNumber = CNLabeledValue(label: "arbitrary string", value: phoneNumber)
contact.phoneNumbers.append(labeledPhoneNumber)
You should implement that screen manually. The screen on your screenshot is a UITableViewController
with a grouped UITableView
and a checkmark accessory indicator for the selected cell.
Here is the list for predefined phone number labels (from the Apple Developer Documentation):
╔════════════════════════════╦═════════════════════╗
║ String ║ Description ║
╠════════════════════════════╬═════════════════════╣
║ CNLabelHome ║ Home label ║
║ CNLabelWork ║ Work label ║
║ CNLabelPhoneNumberiPhone ║ iPhone number ║
║ CNLabelPhoneNumberMobile ║ Mobile phone number ║
║ CNLabelPhoneNumberMain ║ Main phone number ║
║ CNLabelPhoneNumberHomeFax ║ Home fax number ║
║ CNLabelPhoneNumberWorkFax ║ Work fax number ║
║ CNLabelPhoneNumberOtherFax ║ Other fax number ║
║ CNLabelPhoneNumberPager ║ Pager phone number ║
╚════════════════════════════╩═════════════════════╝
To display the localized names of these constants, use CNLabeledValue.localizedString(forLabel:)
(thanks, OOPer):
Swift
let localizedLabelString = CNLabeledValue<NSString>.localizedString(forLabel: CNLabelPhoneNumberiPhone)
print(localizedLabelString) //iPhone
Objective-C
NSString *localizedLabelString = [CNLabeledValue localizedStringForLabel: CNLabelPhoneNumberiPhone];
NSLog(@"%@", localizedLabelString); //iPhone
If you want to create a custom label for a contact, just use an arbitrary string for the label's name:
let phoneNumber = CNPhoneNumber(stringValue: "+18001234567")
let labeledPhoneNumber = CNLabeledValue(label: "arbitrary string", value: phoneNumber)
contact.phoneNumbers.append(labeledPhoneNumber)
edited Nov 26 '18 at 16:44
answered Nov 26 '18 at 2:27
Tamás Sengel
26.4k146793
26.4k146793
Thanks! This should work, but a follow-up question. How about those labels that added as a custom?
– Lysdexia
Nov 26 '18 at 3:01
@Lysdexia If the label's string value is not in the list of predefined constants, then it's a custom label.
– Tamás Sengel
Nov 26 '18 at 3:04
1
Thanks! I've accepted your answer, but a follow-up question. How can I manage the custom labels? Also, the iOS Contacts app has a label of "home", on the documentation it doesn't have it. Do you have any idea?
– Lysdexia
Nov 26 '18 at 9:14
@Lysdexia I added home and work labels to the table, thank you for mentioning this! Also, I've added a section about custom labels to the end.
– Tamás Sengel
Nov 26 '18 at 16:45
add a comment |
Thanks! This should work, but a follow-up question. How about those labels that added as a custom?
– Lysdexia
Nov 26 '18 at 3:01
@Lysdexia If the label's string value is not in the list of predefined constants, then it's a custom label.
– Tamás Sengel
Nov 26 '18 at 3:04
1
Thanks! I've accepted your answer, but a follow-up question. How can I manage the custom labels? Also, the iOS Contacts app has a label of "home", on the documentation it doesn't have it. Do you have any idea?
– Lysdexia
Nov 26 '18 at 9:14
@Lysdexia I added home and work labels to the table, thank you for mentioning this! Also, I've added a section about custom labels to the end.
– Tamás Sengel
Nov 26 '18 at 16:45
Thanks! This should work, but a follow-up question. How about those labels that added as a custom?
– Lysdexia
Nov 26 '18 at 3:01
Thanks! This should work, but a follow-up question. How about those labels that added as a custom?
– Lysdexia
Nov 26 '18 at 3:01
@Lysdexia If the label's string value is not in the list of predefined constants, then it's a custom label.
– Tamás Sengel
Nov 26 '18 at 3:04
@Lysdexia If the label's string value is not in the list of predefined constants, then it's a custom label.
– Tamás Sengel
Nov 26 '18 at 3:04
1
1
Thanks! I've accepted your answer, but a follow-up question. How can I manage the custom labels? Also, the iOS Contacts app has a label of "home", on the documentation it doesn't have it. Do you have any idea?
– Lysdexia
Nov 26 '18 at 9:14
Thanks! I've accepted your answer, but a follow-up question. How can I manage the custom labels? Also, the iOS Contacts app has a label of "home", on the documentation it doesn't have it. Do you have any idea?
– Lysdexia
Nov 26 '18 at 9:14
@Lysdexia I added home and work labels to the table, thank you for mentioning this! Also, I've added a section about custom labels to the end.
– Tamás Sengel
Nov 26 '18 at 16:45
@Lysdexia I added home and work labels to the table, thank you for mentioning this! Also, I've added a section about custom labels to the end.
– Tamás Sengel
Nov 26 '18 at 16:45
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53442582%2fcnlabelphonenumber-label-picker%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
@TamásSengel yup, I was thinking this way too, was just wondering if there a list of labels to get from including the Custom Label part if ever the user adds one.
– Lysdexia
Nov 26 '18 at 1:02