苹果的UIActivityViewController
原问题来自于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’参数来判断是否完成。 --------------------编程问答-------------------- SDFASDcvAC --------------------编程问答-------------------- 除 --------------------编程问答-------------------- 正在研究中正在研究中正在研究中 --------------------编程问答-------------------- 除 --------------------编程问答-------------------- 不错,真的很不错 --------------------编程问答-------------------- 除 --------------------编程问答-------------------- 哎........... --------------------编程问答-------------------- 在研究中正在研究中正在研究中 --------------------编程问答-------------------- 高手!正在研究中 --------------------编程问答-------------------- 界面技术还可以啊。其他就没什么了。 --------------------编程问答-------------------- 除 --------------------编程问答-------------------- 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];
是什么意思呢 --------------------编程问答-------------------- 除 --------------------编程问答-------------------- --------------------编程问答-------------------- 不错的解决方案,学习了.. --------------------编程问答-------------------- 好东西啊!好啊! --------------------编程问答-------------------- 加油啊苹果啊 --------------------编程问答-------------------- 除 --------------------编程问答-------------------- 除 --------------------编程问答-------------------- 也来研究一下 --------------------编程问答-------------------- 应用中用到 UIActivityViewController --------------------编程问答-------------------- 除 --------------------编程问答-------------------- 除 --------------------编程问答-------------------- 高手!正在研究中 --------------------编程问答-------------------- 除 --------------------编程问答-------------------- 好东西,有空试试看! --------------------编程问答-------------------- henhaohenqiangda --------------------编程问答-------------------- 代码没问题,但是我觉得,是否把alertmessage的判断放到done = success里,是不是代码更优化些 --------------------编程问答--------------------
补充:移动开发 , iPhone