苹果的UIActivityViewController

问答小助手 2013-04-27 10:50:43
加精
原问题来自于CSDN问答频道,更多解决方案见:http://ask.csdn.net/questions/2248
问题描述:
应用中用到 UIActivityViewController 。

使用代码:
NSString *postText = @"My Text";
NSArray *activityItems = @[postText];
UIActivityViewController *activityController =
[[UIActivityViewController alloc]
initWithActivityItems:activityItems applicationActivities:nil];
activityController.excludedActivityTypes = [NSArray arrayWithObjects:UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll, nil];
[self presentViewController:activityController
animated:YES completion:nil];

运行正常,从UIActivityViewController打开邮件的时候,也会显示出需要的内容。

现在我要在数据库中执行一些动作,条件是在post或者邮件发送成功之后。

应该怎么做?

解决方案:
[activityController setCompletionHandler:^(NSString *act, BOOL done)
{

NSLog(@"act type %@",act);
NSString *ServiceMsg = nil;
if ( [act isEqualToString:UIActivityTypeMail] ) ServiceMsg = @"Mail sent";
if ( [act isEqualToString:UIActivityTypePostToTwitter] ) ServiceMsg = @"Post on twitter, ok!";
if ( [act isEqualToString:UIActivityTypePostToFacebook] ) ServiceMsg = @"Post on facebook, ok!";

if ( done )
{
UIAlertView *Alert = [[UIAlertView alloc] initWithTitle:ServiceMsg message:@"" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil];
[Alert show];
[Alert release];
}
else
{
// didn't succeed.
}
}];

用完成处理程序的‘done’参数来判断是否完成。
...全文
2377 30 打赏 收藏 转发到动态 举报
写回复
用AI写文章
30 条回复
切换为时间正序
请发表友善的回复…
发表回复
SunGiantor 2014-02-21
  • 打赏
  • 举报
回复
学习了,收藏一下
u010944460 2013-06-03
  • 打赏
  • 举报
回复
Hubbert 2013-06-01
  • 打赏
  • 举报
回复
代码没问题,但是我觉得,是否把alertmessage的判断放到done = success里,是不是代码更优化些
u010598276 2013-05-09
  • 打赏
  • 举报
回复
henhaohenqiangda
Mengoes 2013-05-08
  • 打赏
  • 举报
回复
好东西,有空试试看!
123456tgf 2013-05-05
  • 打赏
  • 举报
回复
高手!正在研究中
szhw66 2013-04-30
  • 打赏
  • 举报
回复
应用中用到 UIActivityViewController
u010506248 2013-04-29
  • 打赏
  • 举报
回复
也来研究一下
u010489324 2013-04-28
  • 打赏
  • 举报
回复
1 2 3 4 5 6 7 8 NSString *postText = @"My Text"; NSArray *activityItems = @[postText]; UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil]; activityController.excludedActivityTypes = www.xsxs.net[NSArray arrayWithObjects:UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll, nil]; [self presentViewController:activityController animated:YES completion:nil]; 是什么意思呢
jeepy 2013-04-28
  • 打赏
  • 举报
回复
界面技术还可以啊。其他就没什么了。
u010495581 2013-04-28
  • 打赏
  • 举报
回复
加油啊苹果啊
u010494778 2013-04-28
  • 打赏
  • 举报
回复
好东西啊!好啊!
叶子 2013-04-28
  • 打赏
  • 举报
回复
不错的解决方案,学习了..
u010493708 2013-04-28
  • 打赏
  • 举报
回复
miaojw 2013-04-27
  • 打赏
  • 举报
回复
高手!正在研究中
xukui2007 2013-04-27
  • 打赏
  • 举报
回复
SDFASDcvAC
u010484949 2013-04-27
  • 打赏
  • 举报
回复
在研究中正在研究中正在研究中
魂音 2013-04-27
  • 打赏
  • 举报
回复
哎...........
Lena521 2013-04-27
  • 打赏
  • 举报
回复
不错,真的很不错
timer&interrupt 2013-04-27
  • 打赏
  • 举报
回复
正在研究中正在研究中正在研究中

29,028

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧