我想触发通过iOS6的内置的“鸣叫表”触发通过iOS6的“推特表”
我希望将用户的tweet东西之后的特定动作的用户鸣叫后动作在用户点击其“发送”按钮后触发一个方法。
或者,如果我可以从iOS获得一些确认发布tweet的消息,那么我想要触发该方法。
这些选项都可能吗?在用户发布推文后是否有不同的首选方式来触发操作?
我想触发通过iOS6的内置的“鸣叫表”触发通过iOS6的“推特表”
我希望将用户的tweet东西之后的特定动作的用户鸣叫后动作在用户点击其“发送”按钮后触发一个方法。
或者,如果我可以从iOS获得一些确认发布tweet的消息,那么我想要触发该方法。
这些选项都可能吗?在用户发布推文后是否有不同的首选方式来触发操作?
使用完成处理程序。看下面的代码示例。
SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
tweetSheet.completionHandler = ^(SLComposeViewControllerResult result) {
switch(result) {
// This means the user cancelled without sending the Tweet
case SLComposeViewControllerResultCancelled:
break;
// This means the user hit 'Send'
case SLComposeViewControllerResultDone:
break;
}
dispatch_async(dispatch_get_main_queue(), ^{
[self dismissViewControllerAnimated:NO completion:^{
NSLog(@"Tweet Sheet has been dismissed.");
}];
});
};
-(void)shareViewTwitter:(NSString*)str
{
TWTweetComposeViewController *twitter = [[TWTweetComposeViewController alloc] init];
// Optional: set an image, url and initial text
[twitter setInitialText:@"Some Text"];
// Show the controller
[self presentModalViewController:twitter animated:YES];
// Called when the tweet dialog has been closed (Here your Action will be triggered)
twitter.completionHandler = ^(TWTweetComposeViewControllerResult result)
{
NSString *title = @"Tweet Status";
NSString *msg;
if (result == TWTweetComposeViewControllerResultCancelled)
// Your Action
msg = @"Tweet compostion was canceled.";
else msg = @"Tweet composition completed."; // Your Action
// Show alert to see how things went...
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
[alertView show];
// Dismiss the controller
[self dismissModalViewControllerAnimated:YES];
};
}
工程太棒了!谢谢! –
欢迎您^ _ ^ – Atrash
感谢您的答复。你能指点我一个访问这些控制器的资源吗? –