在美洲狮上,我使用AppKit.framework的NSSharingService类尝试了新的共享可能性
使用这种代码一切都很顺利
NSArray* array = @[ @"myText", [NSImage imageNamed:@"myImageFile"] ];
NSSharingService* sharingServiceFB = [NSSharingService sharingServiceNamed:NSSharingServiceNamePostOnFacebook];
[sharingServiceFB performWithItems:array];但是我想在不使用performWithItems函数生成的共享窗口的情况下做同样的事情。因为我考虑到我的应用程序的用户不想确认他想要发送消息,因为他已经选择了。我在这个类中没有看到任何“直接投递”函数。需要用另一种方式来做吗?
发布于 2013-04-13 09:52:31
除了自己实现Facebook的API之外,没有其他方法可以做到这一点,但如果您不介意窗口出现半秒钟:
- (void)whatever {
NSArray* array = @[ @"myText", [NSImage imageNamed:@"myImageFile"] ];
NSSharingService* sharingServiceFB = [NSSharingService sharingServiceNamed:NSSharingServiceNamePostOnFacebook];
[sharingServiceFB performWithItems:array];
[self performSelector:@selector(pressReturn) withObject:nil afterDelay:0.5];
}
- (void)pressReturn {
CGEventRef keypress = CGEventCreateKeyboardEvent(NULL, 36, TRUE);
CGEventPost(kCGHIDEventTap, keypress);
}你的用户可能不会喜欢它...
https://stackoverflow.com/questions/14053808
复制相似问题