从本地iOS联系应用程序获取与钛的联系方式[英] Get contact details to titanium from native iOS contact app

本文是小编为大家收集整理的关于从本地iOS联系应用程序获取与钛的联系方式的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我是钛的新手. 目前,我正在研究一个项目,用户需要使用iOS联系人应用程序的联系方式.

我的app.js看起来像这个

Window = require('ui/handheld/ApplicationWindow');
var win = Window();
win.open();
var button = Ti.UI.createButton({
    title : 'Show Contacts',
    width : 100,
    height: 50,
});
win.add(button);
button.addEventListener('click',function(e){
    Titanium.Contacts.showContacts({ });
});

当我单击按钮时,显示以下代码:

联系人列表

当我选择联系人时,细节显示在另一个屏幕上:

联系人详细信息

但是我不想要这个,当用户选择单个联系人时,详细信息应传递给我的app.js文件.而且无需转到详细信息页面.

有什么方法可以做到吗? 请帮我. 预先感谢.

推荐答案

最后我得到了.

我使用以下代码:

button.addEventListener('click',function(e){
    Titanium.Contacts.showContacts(values);
});
var values = {cancel:function(){}};
values.fields = ['firstName', 'lastName', 'phone'];

values.selectedProperty = function(e) {
                var cn = e.person.firstName; 
                var sn = e.person.lastName;
                alert('Name'+cn+' '+sn);
};

参考: p>

其他推荐答案

似乎您缺少选择一个人时要调用的函数声明:

Titanium.Contacts.showContacts({/*missing selectedPerson callback object*/});

您可以阅读更多有关哪些参数可以传递到showContacts方法这里.

其他推荐答案

var parms = {
animated : true,
selectedPerson : function(e) {
    alert(e.person);
}

}; Titanium.Contacts.showContacts(parms);

您将在e.person对象中获取选定人的详细信息.可以根据您的要求将其传递给app.js等.我只是在警报中显示了它.

本文地址:https://www.itbaoku.cn/post/1938177.html

问题描述

I'm new to Titanium. Currently I'm working on a project in this the user needs to use the contact details from iOS contacts App.

My app.js looks like this

Window = require('ui/handheld/ApplicationWindow');
var win = Window();
win.open();
var button = Ti.UI.createButton({
    title : 'Show Contacts',
    width : 100,
    height: 50,
});
win.add(button);
button.addEventListener('click',function(e){
    Titanium.Contacts.showContacts({ });
});

When I click on a button the following code is displayed:

Contact list

And when I select an contact the detail is displayed on the other screen:

Contact details

But I don't want this, When the user selects an individual contact the details should be passed to my app.js file. And no need to go to the details page.

Is there any way to do this ? Please help me. Thanks in advance.

推荐答案

Finally I got it.

I used the following code:

button.addEventListener('click',function(e){
    Titanium.Contacts.showContacts(values);
});
var values = {cancel:function(){}};
values.fields = ['firstName', 'lastName', 'phone'];

values.selectedProperty = function(e) {
                var cn = e.person.firstName; 
                var sn = e.person.lastName;
                alert('Name'+cn+' '+sn);
};

Reference : Titanium Contacts

其他推荐答案

It seems that you're missing a declaration of function to be called when a person is selected:

Titanium.Contacts.showContacts({/*missing selectedPerson callback object*/});

You can read more on what parameters can be passed into showContacts method here.

其他推荐答案

var parms = {
animated : true,
selectedPerson : function(e) {
    alert(e.person);
}

}; Titanium.Contacts.showContacts(parms);

You will get the details of selected person in e.person object. that can be passed to app.js etc according to your requirements. i just showed it in the alert.