Col*_*lin 7 ios completionhandler uiactivityviewcontroller
在我的UIActivityViewController中,我使用完成处理程序来执行"成功共享"通知.它可以工作,但我唯一的问题是,如果用户按下取消,它仍会显示通知.
这是我的完成处理程序代码,
[controller setCompletionHandler:^(NSString *activityType, BOOL completed) {
CWStatusBarNotification *notification = [CWStatusBarNotification new];
[notification displayNotificationWithMessage:@"? Successfully Shared Centre!"
forDuration:3.0f];
notification.notificationLabelBackgroundColor = [UIColor colorWithRed:38.0f/255.0f green:81.0f/255.0f blue:123.0f/255.0f alpha:1.0f];
notification.notificationLabelTextColor = [UIColor whiteColor];
}];
Run Code Online (Sandbox Code Playgroud)
谢谢您的帮助!
Jya*_*aif 19
注意:在iOS8中不推荐使用completionHandler属性,因此不可能再知道共享操作的结果.
https://developer.apple.com/documentation/uikit/uiactivityviewcontroller/1622010-completionhandler
更新:就像adruzh所说,在iOS8上有一个新的completionHandler,Apple在文档中忘了提及:
[activityController setCompletionWithItemsHandler:
^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError) {
}];
Run Code Online (Sandbox Code Playgroud)
Nic*_*rge 13
这就是completed争论的结果:
[controller setCompletionHandler:^(NSString *activityType, BOOL completed) {
if (!completed) return;
CWStatusBarNotification *notification = [CWStatusBarNotification new];
[notification displayNotificationWithMessage:@"? Successfully Shared Centre!"
forDuration:3.0f];
notification.notificationLabelBackgroundColor = [UIColor colorWithRed:38.0f/255.0f green:81.0f/255.0f blue:123.0f/255.0f alpha:1.0f];
notification.notificationLabelTextColor = [UIColor whiteColor];
}];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15416 次 |
| 最近记录: |