现在有个需求就是如何调用手机通讯录的UI界面,安卓已经写出来了,就是iOS怎么都调不出来?我是这么写的:
// #import <AddressBook/AddressBook.h>
// #import <AddressBookUI/AddressBookUI.h>
var abPicker = plus.ios.newObject('ABPeoplePickerNavigationController');
var viewcontroller = plus.ios.newObject('UIViewController');
plus.ios.invoke(viewcontroller,"presentViewController:animated:completion:",abPicker,true,null,'yes');
我是直接将iOS的源码翻译过来的,可是就是不出来。
1***@qq.com (作者)
我想直接调iPhone的通讯录UI界面出来,像安卓一个样都可以直接调出原生的UI界面出来,iOS目前做不了吗?如安卓:
var s_ret = null;
var REQUESTCODE = 1000;
main = plus.android.runtimeMainActivity();
var Intent = plus.android.importClass('android.content.Intent');
var ContactsContract = plus.android.importClass('android.provider.ContactsContract');
var intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
main.onActivityResult = function(requestCode, resultCode, data) {
if (REQUESTCODE == requestCode) {
var phoneNumber = null;
var resultString = "";
var context = main;
plus.android.importClass(data);
var contactData = data.getData();
var resolver = context.getContentResolver();
plus.android.importClass(resolver);
var cursor = resolver.query(contactData, null, null, null, null);
plus.android.importClass(cursor);
cursor.moveToFirst();
var givenName = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
s_ret = givenName;
var contactId = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
var pCursor = resolver.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = " + contactId,
null, null);
while (pCursor.moveToNext()) {
phoneNumber = pCursor.getString( pCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
s_ret += '--' + phoneNumber;
}
var rets = new Array();
rets = s_ret.split("--");
cphone.val(rets[1]);
cname.val(rets[0]);
cursor.close();
pCursor.close();
}
};
main.startActivityForResult(intent, REQUESTCODE);
2016-07-19 10:23
Trust
可以读取数据后,自定义UI将数据渲染出来。
2016-07-19 10:27
1***@qq.com (作者)
回复 Trust:这是不是麻烦了点啊,安卓都可以直接访问通讯录界面的啊
2016-07-19 10:41