2013-04-11 1 views
0

iPhone 앱에서 HTML 형식의 이메일을 보내고 있습니다. 응용 프로그램 패키지 내에 저장된 HTML 파일을 읽는 중입니다.iphone 용 인앱 이메일에서 보낼 런타임 정보를 HTML 파일로 보냅니다.

이제 HTML 파일 내의 특정 텍스트를 변경하고 싶습니다. 앱의 사용자가 특정 선택에 따라 변경되는 이름, 이메일 및 전화가 있습니다.

이러한 다양한 매개 변수를 HTML 파일 콘텐츠에 추가하는 방법은 무엇입니까?

도와주세요. 이 같은

답변

2

뭔가가 당신을 위해 작동 할 수

감사 :

NSString *htmlPath = [[NSBundle mainBundle] pathForResource:@"yourHtml" ofType:@"html"]; 

NSError *error = nil; 

NSString *inputHtml = [[NSString alloc] initWithContentsOfFile:htmlPath encoding:NSUTF8StringEncoding error:&error]; 

NSString *nameParsedHtml = [inputHtml stringByReplacingOccurrencesOfString:@"Name:" withString:[NSString stringWithFormat:@"Name: %@", self.nameField.text]]; 

NSString *emailParsedHtml = [nameParsedHtml stringByReplacingOccurrencesOfString:@"Email:" withString:[NSString stringWithFormat:@"Email: %@", self.emailField.text]]; 

NSString *outputHtml = [emailParsedHtml stringByReplacingOccurrencesOfString:@"Phone:" withString:[NSString stringWithFormat:@"Phone: %@", self.phoneField.text]]; 

NSLog(@"Output html string is: %@", outputHtml); 
+1

감사합니다 ... 마법처럼 작동합니다. – iOSDev

+0

@AsifHabib 설명하고 새로운 질문과 링크를 여기에 게시하십시오 – klcjr89

+0

교차 체크! 지금 일하고있어! 내 편이 잘못됐다! – AsifHabib

관련 문제