0

iPhone アプリ内から HTML 形式のメールを送信しています。アプリケーション パッケージ内に格納されている HTML ファイルを読み込んでいます。

ここで、HTML ファイル内の特定のテキストを変更したいと考えています。つまり、アプリでのユーザーの特定の選択に応じて変更される名前、電子メール、電話があります。

これらのさまざまなパラメーターを HTML ファイルのコンテンツに追加するにはどうすればよいですか?

助けてください。

ありがとう

4

1 に答える 1

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);
于 2013-04-12T01:04:25.407 に答える