嗨,我在 iOS 应用中有两个 UIButton。一是在推特上发帖,二是在脸书上发帖。facebook 按钮完美运行,但推文给我带来了一些问题,推文表将打开填充文本,但需要两次点击取消按钮才能关闭。如果我点击发送,则将发送推文并关闭工作表,但我的应用程序冻结并变得无响应。我已经包含了这两个代码
- (IBAction)postTweet:(id)sender {
// if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]){
myTweet = [[SLComposeViewController alloc]init];
myTweet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
NSString *tweetString = [[NSString alloc]initWithFormat:@"%@\n%@\nvia @ValuatorApp", pdOne.text, pdTwo.text];
[myTweet setInitialText:tweetString];
[myTweet addURL:[NSURL URLWithString:@"http://sjb007.me/TheValuator"]];
[self presentViewController:myTweet animated:YES completion:nil];
// }
[myTweet setCompletionHandler:^(SLComposeViewControllerResult result) {
NSString *output = [[NSString alloc]init];
switch (result) {
case SLComposeViewControllerResultCancelled:
output = @"Twitter Post Cancelled";
break;
case SLComposeViewControllerResultDone:
output = @"Twitter post Succesful";
break;
default:
break;
}
NSLog(@"%@",output);
}];
}
- (IBAction)postFacebook:(id)sender {
// if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]){
myTweet = [[SLComposeViewController alloc]init];
myTweet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
if (pd3 != 0) {
NSString *facebookString = [[NSString alloc]initWithFormat:@"%@\n%@\n%@", pdOne.text,pdTwo.text, pdThree.text];
[myTweet setInitialText:facebookString];
}
else if (pd3 == 0){
NSString *facebookString = [[NSString alloc]initWithFormat:@"%@\n%@\n", pdOne.text,pdTwo.text];
[myTweet setInitialText:facebookString];
}
// [myTweet addImage:[UIImage imageNamed:@"Photo Jun 02, 22 46 37.jpg"]];
[myTweet addURL:[NSURL URLWithString:@"http://sjb007.me/TheValuator"]];
[self presentViewController:myTweet animated:YES completion:nil];
// }
[myTweet setCompletionHandler:^(SLComposeViewControllerResult result) {
NSString *output = [[NSString alloc]init];
switch (result) {
case SLComposeViewControllerResultCancelled:
output = @"Facebook Post Cancelled";
break;
case SLComposeViewControllerResultDone:
output = @"Facebook post Succesful";
break;
default:
break;
}
NSLog(@"%@",output);
}];
}