如何为使用NSSharingService组成的邮件消息定义主题?
我经历过NSSharingService Class reference,但我没有看到它在任何地方定义。以下成功启动邮件应用程序,但主题只是与文本一起推入邮件正文。
NSAttributedString *text = [self.noteSynopsisView attributedString];
NSString *subject = @"My Subject";
NSArray *shareItems = [NSArray arrayWithObjects:text, subject, nil];
NSSharingServicePicker *sharingServicePicker = [[NSSharingServicePicker alloc] initWithItems:shareItems];
sharingServicePicker.delegate = self;
[sharingServicePicker showRelativeToRect:[self.shareButton bounds] ofView:self.shareButton preferredEdge:NSMaxYEdge];
在iOS中,您通常会执行以下操作来定义MailComposer的主题
[sharingServicePicker setSubject:@"My Subject"];
但SharingServicePicker不支持setSubject。
答案 0 :(得分:2)
自OS X 10.9起,NSSharingService
具有subject
属性,您可以使用。
答案 1 :(得分:0)
实施下一个方法:
-(id<NSSharingServiceDelegate>)sharingServicePicker:(NSSharingServicePicker *)sharingServicePicker delegateForSharingService:(NSSharingService *)sharingService{
sharingService.subject=@"Subject";
return self;
}