【问题标题】:How to Show Contact is Selected in ios如何在ios中选择显示联系人
【发布时间】:2011-10-15 05:42:04
【问题描述】:

我正在处理通讯录,现在我想显示我在通讯录中选择的联系人应该以蓝色显示...

AS LIKE IN IPHONE WE CAN SEE ...

为此我做了这么多的编码......

 ABRecordRef person = NULL;
    NSString *name = nil;
    if(gPerson == NULL)
    {
        person = ABPersonCreate();
        name = strReceiversNames;
    }
    else
    {
        person = gPerson;
        NSString *fName = (NSString*)ABRecordCopyValue(gPerson, kABPersonFirstNameProperty);
        NSString *lName = (NSString*)ABRecordCopyValue(gPerson, kABPersonLastNameProperty);
        name = [NSString stringWithFormat:@"%@ %@", fName, lName];
    }

    CFErrorRef  error = NULL;

    //UILabel *ContectInfo;
//  ContectInfo.text = strPhoneNumber;
//  ContectInfo.textColor = [UIColor greenColor];
    // set name
    ABRecordSetValue(person, kABPersonFirstNameProperty, (CFStringRef)name, &error);

    // set phone number
    ABMutableMultiValueRef phoneNumber = ABMultiValueCreateMutable(kABMultiStringPropertyType);
    ABMultiValueAddValueAndLabel(phoneNumber, (CFStringRef)strPhoneNumber, kABPersonPhoneMobileLabel,NULL);
    ABRecordSetValue(person, kABPersonPhoneProperty, phoneNumber, &error);
    CFRelease(phoneNumber);

    if(error != NULL) 
    {
        NSLog(@"Error: %@", error);
    }

    ABPersonViewController *ctrl = [[ABPersonViewController alloc] init];

在这个 strPhoneNumber 是我的联系电话.. 我只想在单击按钮时将其显示为蓝色 ....

strPhoneNumber 是 NSString ..

提前致谢

【问题讨论】:

    标签: ios colors contacts addressbook


    【解决方案1】:

    为什么不使用 ABPersonViewController 的 setHighlightedItemForProperty:withIdentifier: 方法?或者也许改变 displayPerson 属性?希望这能给你一个好的方向。

    【讨论】:

      【解决方案2】:

      你应该这样使用。

      在您选择联系人时使用它。

      ABPersonViewController *ctrl = [[ABPersonViewController alloc] init];
      [ctrl setHighlightedItemForProperty:kABPersonPhoneProperty withIdentifier:0];
      

      最后调用这个函数

      - (void)setHighlightedItemForProperty:(ABPropertyID)property withIdentifier:(ABMultiValueIdentifier)identifier
      {
      
      }
      

      所以现在你从地址簿中选择的号码显示为蓝色......

      【讨论】:

        猜你喜欢
        • 2019-02-22
        • 2017-02-05
        • 1970-01-01
        • 2017-05-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多