Iphone 消息正文中的字符串不工作
我实现了下面的代码,并记录了Iphone 消息正文中的字符串不工作,iphone,nsstring,mfmailcomposeviewcontroller,Iphone,Nsstring,Mfmailcomposeviewcontroller,我实现了下面的代码,并记录了arrayPlainText,但当我在模拟器和iPhone上运行它时,它只显示第一项,其他所有内容都消失了 NSMutableArray *xmlListContent; NSFileManager *fileManager = [NSFileManager defaultManager]; if ([fileManager fileExistsAtPath:[self returnListPath]]) { xmlListCo
arrayPlainText
,但当我在模拟器和iPhone上运行它时,它只显示第一项,其他所有内容都消失了
NSMutableArray *xmlListContent;
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:[self returnListPath]])
{
xmlListContent = [[NSMutableArray alloc] initWithContentsOfFile:[self returnListPath]];
NSMutableArray *listContent = [[NSMutableArray alloc] init];
int i;
for(i = 0; i < [xmlListContent count]; i++)
{
MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc] init];
[mailComposer setMailComposeDelegate:self];
if ([MFMailComposeViewController canSendMail]) {
[mailComposer setSubject:editedListTitle];
[mailComposer setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
NSString *item = [NSString stringWithString:[[xmlListContent objectAtIndex:i] objectForKey:@"label"]];
NSString *tempString = [NSString stringWithFormat:@"-%@",item];
[listContent addObject:tempString];
NSString *arrayPlainText = [listContent componentsJoinedByString:@"<br>"];
[mailComposer setMessageBody:[NSString stringWithFormat:@"<html>%@</html>",arrayPlainText] isHTML:YES];
DLog(arrayPlainText);
[self presentModalViewController:mailComposer animated:YES];
}
}
}
else
{
xmlListContent = [NSMutableArray array];
DLog(@"failed to compose list via email");
}
NSMutableArray*xmlListContent;
NSFileManager*fileManager=[NSFileManager defaultManager];
如果([fileManager fileExistsAtPath:[self returnListPath]])
{
xmlListContent=[[NSMutableArray alloc]initWithContentsOfFile:[self returnListPath]];
NSMutableArray*listContent=[[NSMutableArray alloc]init];
int i;
对于(i=0;i<[xmlListContent count];i++)
{
MFMailComposeViewController*mailComposer=[[MFMailComposeViewController alloc]init];
[mailComposer setMailComposeDelegate:self];
如果([MFMailComposeViewController canSendMail]){
[mailComposer设置主题:editedListTitle];
[mailComposer SetModAltTransitionStyle:UIModAltTransitionStyleCoverVertical];
NSString*item=[NSString stringWithString:[[xmlListContent objectAtIndex:i]objectForKey:@“标签”];
NSString*tempString=[NSString stringWithFormat:@“-%@”,项];
[listContent-addObject:tempString];
NSString*arrayPlainText=[listContent组件通过字符串连接:@“
”;
[mailComposer setMessageBody:[NSString stringWithFormat:@“%@”,ArrayPlaintText]isHTML:是];
DLog(arrayPlainText);
[self-presentModalViewController:mailComposer动画:是];
}
}
}
其他的
{
xmlListContent=[NSMutableArray];
DLog(@“无法通过电子邮件撰写列表”);
}
这个代码怎么样:
NSString *item = [NSString stringWithString:[[self.array objectAtIndex:i] objectForKey:@"label"]];
NSString *tempString = [NSString stringWithFormat:@"-%@",item];
[listContent addObject:tempString];
NSString *arrayPlainText = [listContent componentsJoinedByString:@"<br>"];
[mailComposer setMessageBody:[NSString stringWithFormat:@"<html>%@</html>",arrayPlainText] isHTML:YES];
DLog(arrayPlainText);
NSString*item=[NSString stringWithString:[[self.array objectAtIndex:i]objectForKey:@“label”];
NSString*tempString=[NSString stringWithFormat:@“-%@”,项];
[listContent-addObject:tempString];
NSString*arrayPlainText=[listContent组件通过字符串连接:@“
”;
[mailComposer setMessageBody:[NSString stringWithFormat:@“%@”,ArrayPlaintText]isHTML:是];
DLog(arrayPlainText);
答案就在这里
NSMutableArray *xmlListContent;
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:[self returnListPath]])
{
xmlListContent = [[NSMutableArray alloc] initWithContentsOfFile:[self returnListPath]];
NSMutableArray *listContent = [[NSMutableArray alloc] init];
int i;
for(i = 0; i < [xmlListContent count]; i++)
{
NSString *item = [[xmlListContent objectAtIndex:i] objectForKey:@"label"];
NSString *tempString = [NSString stringWithFormat:@"-%@", item];
[listContent addObject:tempString];
}
NSString *arrayPlainText = [listContent componentsJoinedByString:@"<br>\n"];
DLog(arrayPlainText);
if ([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc] init];
[mailComposer setMailComposeDelegate:self];
[mailComposer setSubject:editedListTitle];
[mailComposer setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[mailComposer setMessageBody:[NSString stringWithFormat:@"<html>%@</html>",arrayPlainText] isHTML:YES];
[self presentModalViewController:mailComposer animated:YES];
}
else
{
xmlListContent = [NSMutableArray array];
DLog(@"failed to compose list via email");
}
}
NSMutableArray*xmlListContent;
NSFileManager*fileManager=[NSFileManager defaultManager];
如果([fileManager fileExistsAtPath:[self returnListPath]])
{
xmlListContent=[[NSMutableArray alloc]initWithContentsOfFile:[self returnListPath]];
NSMutableArray*listContent=[[NSMutableArray alloc]init];
int i;
对于(i=0;i<[xmlListContent count];i++)
{
NSString*item=[[xmlListContent对象索引:i]objectForKey:@“标签”];
NSString*tempString=[NSString stringWithFormat:@“-%@”,项];
[listContent-addObject:tempString];
}
NSString*arrayPlainText=[listContent componentsJoinedByString:@“
\n”];
DLog(arrayPlainText);
如果([MFMailComposeViewController canSendMail]){
MFMailComposeViewController*mailComposer=[[MFMailComposeViewController alloc]init];
[mailComposer setMailComposeDelegate:self];
[mailComposer设置主题:editedListTitle];
[mailComposer SetModAltTransitionStyle:UIModAltTransitionStyleCoverVertical];
[mailComposer setMessageBody:[NSString stringWithFormat:@“%@”,ArrayPlaintText]isHTML:是];
[self-presentModalViewController:mailComposer动画:是];
}
其他的
{
xmlListContent=[NSMutableArray];
DLog(@“无法通过电子邮件撰写列表”);
}
}
如果打印arrayPlainText的内容,它是否包含所有的值?是的,它具有所有完整的输出,但是当它在composer中时,它没有。您能提供更多的代码吗?您使用的变量没有向我们显示它们的声明。