gpt4 book ai didi

IOS/objective-C : UIActivityItemSource Protocol for customizing share messages with UIActivityViewController

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:30:12 28 4
gpt4 key购买 nike

Apple 文档说您可以使用 UIActivityItemSource 协议(protocol)来自定义与 UIActivityViewController 共享的消息,以代替 UIActivityItemProvider 对象:

UIActivityItemSource

You can use this protocol in situations where you want to provide the data from one of your app’s existing objects instead of creating a separate UIActivityItemProvider object.

我已经采用了这个协议(protocol),但是,如下所示的委托(delegate)方法似乎没有触发。任何人都可以确认这应该有效,如果是这样,请指出我可能缺少的东西?提前感谢您的任何建议。

-(NSString *)activityViewController:(UIActivityViewController *)activityViewController subjectForActivityType:(UIActivityType)activityType
{
NSLog(@"DELEGATE METHOD CALLED");//Not logging to console

if (activityType == UIActivityTypeMessage) {
return @"My message";
} else if (activityType == UIActivityTypeMail) {
return @"My email text";
}
else {
return @"My default text";
}
}

最佳答案

是的,这个委托(delegate)方法对我有用,调用了委托(delegate)方法。我使用以下代码创建事件项 Controller :

NSArray *theItems = @[ self ];
UIActivityViewController *theController = [[UIActivityViewController alloc] initWithActivityItems:theItems applicationActivities:nil];

theController.popoverPresentationController.barButtonItem = self.shareButton;
theController.excludedActivityTypes = @[ UIActivityTypeAssignToContact,
UIActivityTypeSaveToCameraRoll, UIActivityTypePostToFlickr,
UIActivityTypePostToVimeo, UIActivityTypeAirDrop ];
[self presentViewController:theController animated:YES completion:NULL];

其中 self 实现了 UIActivityItemSource

关于IOS/objective-C : UIActivityItemSource Protocol for customizing share messages with UIActivityViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49012660/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com