2012-10-30 39 views
6

如何定義使用NSSharingService組成的郵件主題?使用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。

回答

2

從OS X 10.9開始,NSSharingService有一個subject屬性,您可以使用它。

+0

如果([mailShare respondsToSelector:@selector(SETSUBJECT :)] [mailShare SETSUBJECT:@ 「主題」]; – Borzh

0

實現下一個方法:

-(id<NSSharingServiceDelegate>)sharingServicePicker:(NSSharingServicePicker *)sharingServicePicker delegateForSharingService:(NSSharingService *)sharingService{ 
    [email protected]"Subject"; 
    return self; 
}