我正在爲Qr生成器應用程序工作,爲此我有很好的kyupay庫。如何在iphone中創建聯繫人二維碼
在該庫中,我需要傳遞字符串值並返回QR圖像。
它的工作文本,電子郵件和等好...
,但現在我想創建QR圖片的聯繫和活動,我不知道如何做到這一點。
所以我的問題是應該是什麼邏輯?
請給我建議,或者如果你有代碼,那麼請分享它。
我正在爲Qr生成器應用程序工作,爲此我有很好的kyupay庫。如何在iphone中創建聯繫人二維碼
在該庫中,我需要傳遞字符串值並返回QR圖像。
它的工作文本,電子郵件和等好...
,但現在我想創建QR圖片的聯繫和活動,我不知道如何做到這一點。
所以我的問題是應該是什麼邏輯?
請給我建議,或者如果你有代碼,那麼請分享它。
感謝您回覆我的問題。
我終於創建了一個返回聯繫人Qr碼字符串的函數。
這很容易但太長。
我們必須檢查來自用戶的數據輸入並按照數據添加sting並創建字符串。
我發佈我的代碼,以便它可以幫助他人並節省他們的時間。
-(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 [email protected]"";
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;
}
由於....
如果您在此網站創建聯繫人QR代碼:http://zxing.appspot.com/generator/它爲您提供了它用來創建QR碼的字符串。也許你可以用它作爲靈感?
hello Eli,..感謝您的鏈接,但我認爲我需要檢查每個數據if..else循環,然後創建這樣的字符串... –
我需要通過串這樣BEGIN:VCARD N; CHARSET = UTF-8:巴比; sarafaraz ;;; FN;字符集= UTF-8:sarafaraz芭 TITLE;字符集= UTF-8:軟件開發 TEL; WORK:1234567489 TEL; CELL:12345875 EMAIL;因特網; WORK; CHARSET = UTF-8:薩菲@ logisticinfotech .com ADR; WORK; CHARSET = utf-8 :;;; Rajkot; Guarat ;;印度 版本:2.1 結束:VCARD –
我從掃描聯繫qr代碼得到這個字符串.. –
是這樣的任何幫助? http://snapmyinfo.com/blog/how-to-create-a-business-card-qr-code/ –