1

我正在为 Qr 生成器应用程序工作,为此我有很好的 kyupay 库。

在那个库中,我需要传递字符串值并返回 QR 图像。

它适用于文本、电子邮件等...

但现在我想为联系人和事件创建 QR 图像而且我不知道该怎么做。

所以我的问题是应该是什么逻辑????

请建议我,或者如果您有代码,请分享。

4

2 回答 2

2

Thanks for respond me on my question.

I finally creates a function that returns contact Qr code string.

It's easy but too long.

we have to check for data inputs from user and append sting as per data and create string.

I am Posting my code so it may help others and save theirs time.

-(NSString *)GenerateStringForContact{

    NSString *str = @"";
    NSMutableArray *arr1 =[[NSMutableArray alloc] init];

    for (int i=0 ; i<[arrayAttributeName count]; i++) {

        if ([[arrayAttributeName objectAtIndex:i] isEqualToString:@"First Name"]) {
            if ([strContactType isEqualToString:@"ContactMecard"]) {
             [arr1 addObject:@"N:"];
            }else{
             [arr1 addObject:@"FN:"];   
            }
        }else if ([[arrayAttributeName objectAtIndex:i] isEqualToString:@"Last Name"]) {
//            [arr1 addObject:@"N:"];
        }else if ([[arrayAttributeName objectAtIndex:i] isEqualToString:@"Phone"]) {
            [arr1 addObject:@"TEL:"];
        }else if ([[arrayAttributeName objectAtIndex:i] isEqualToString:@"Email"]) {
            [arr1 addObject:@"EMAIL:"];
        }else if ([[arrayAttributeName objectAtIndex:i] isEqualToString:@"URL"]) {
            [arr1 addObject:@"URL:"];
        }else if ([[arrayAttributeName objectAtIndex:i] isEqualToString:@"Nickname"]) {
            [arr1 addObject:@"NICKNAME:"];
        }else if ([[arrayAttributeName objectAtIndex:i] isEqualToString:@"Title"]) {
            [arr1 addObject:@"TITLE:"];
        }else if ([[arrayAttributeName objectAtIndex:i] isEqualToString:@"Organization"]) {
            [arr1 addObject:@"ORG:"];
        }else if ([[arrayAttributeName objectAtIndex:i] isEqualToString:@"Birthday"]) {
            [arr1 addObject:@"BDAY:"];
        }else if ([[arrayAttributeName objectAtIndex:i] isEqualToString:@"Note"]) {
            [arr1 addObject:@"NOTE:"];
        }

    }

    NSMutableArray *contDetail = arrayAttributeValue;

    if ([strContactType isEqualToString:@"ContactMecard"]) {
        str = @"MECARD:";
//         arr1 = [[NSArray alloc] initWithObjects:@"N:",@"TEL:",@"EMAIL:",@"URL:",@"NOTE:",@"NICKNAME:",@"BDAY:",@"ADR:",nil];

    }else{

       str = @"BEGIN:VCARD";
//       arr1 = [[NSArray alloc] initWithObjects:@"N:",@"TEL:",@"EMAIL:",@"URL:",@"NOTE:",@"NICKNAME:",@"BDAY:",@"ADR:",@"TITLE:",@"ORG:",nil];
    }

    BOOL count = TRUE;
    for (int i =0; i <[contDetail count]; i++) {

        if (![[contDetail objectAtIndex:i] isEqualToString:@""]) {

            NSString *tmp2 =@"";

            if (i == 0 || i == 1) {
                if (count) {


                    if ([strContactType isEqualToString:@"ContactMecard"]) {

                        tmp2 = [NSString stringWithFormat:@"%@,%@",[contDetail objectAtIndex:0],[contDetail objectAtIndex:1]];

                        NSString *tmp = [NSString stringWithFormat:@"%@%@",[arr1 objectAtIndex:i],tmp2];

                    str = [NSString stringWithFormat:@"%@;%@",str,tmp];

                    }else{
                        tmp2 = [NSString stringWithFormat:@"%@ %@",[contDetail objectAtIndex:0],[contDetail objectAtIndex:1]];

                        NSString *tmp = [NSString stringWithFormat:@"%@%@",[arr1 objectAtIndex:i],tmp2];

                        str = [NSString stringWithFormat:@"%@\n%@",str,tmp];
                    }

                    count = FALSE;
                }

            }else{

                tmp2 = [contDetail objectAtIndex:i];
                NSString *tmp = [NSString stringWithFormat:@"%@%@",[arr1 objectAtIndex:i-1],tmp2];

                if ([strContactType isEqualToString:@"ContactMecard"]) {

                    str = [NSString stringWithFormat:@"%@;%@",str,tmp];

                }else{
                    str = [NSString stringWithFormat:@"%@\n%@",str,tmp];
                }


            }

        }
    }

    if (![strContactType isEqualToString:@"ContactMecard"]) {
        str = [NSString stringWithFormat:@"%@\nEND:VCARD",str];


    }
    NSLog(@"here string for generate code %@",str);    

    return str;
}

Thanks....

于 2012-09-18T11:52:21.437 回答
0

如果您在此站点创建联系人二维码:http: //zxing.appspot.com/generator/它会为您提供用于创建二维码的字符串。也许你可以以此为灵感?

于 2012-05-02T13:28:19.577 回答