-2

我知道如何添加应用程序电子邮件,但我不知道如何通过电子邮件发送表格视图的文本。我有,但我的问题是,当用户在表格中添加一个单元格时,我如何让它也打印出来?打印出我通常会使用的文本

string = [[NSString alloc]initWithFormat:@"%@ \n %@ \n %@",[array objectAtIndex:0], 
                                                           [array objectAtIndex:1], 
                                                           [array objectAtIndex:2]];

我将电子邮件正文设置为字符串。有谁知道如果添加了新单元格,我可以将其添加到电子邮件正文中吗?

谢谢

4

3 回答 3

2

我不是 100% 确定我理解你的问题,但这里有。. .

您可以使您的代码处理超过固定数量的项目,如下所示:

string = [array componentsJoinedByString:@" \n "];

如果array也是您的表格视图的数据源,那么string应该包含所有表格单元格,它们之间有一个中断。


在向用户显示电子邮件视图之前,您只能在 MFMailComposeViewController 中更新电子邮件的正文- 一旦显示,它就是只读的:(

于 2011-07-15T16:39:33.657 回答
0

我在这里假设您的数组中填充了字符串对象。

编写字符串:

NSString *theMessage = [NSString stringWithFormat:@"%@ \n %@ \n %@,", [array objectAtIndex:0], [array objectAtIndex:1], [array objectAtIndex:2]];

现在,假设您还有一个MailViewController实例,实例化为mailViewController,为正文编写以下代码:

[mailViewController setMessageBody:theMessage isHTML:NO];
于 2011-07-15T16:43:20.863 回答
0

首先使用上面指示的方法填充UItableView字符串的格式,然后在您的:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

UITableViewCell *cellView = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:indexPath.row inSection:0]];//Section 0  
NSString *string=cellView.textLabel.text;
//compose email body with string

希望这可以帮助。

于 2011-07-15T17:56:26.280 回答