我曾尝试使用 SLComposeViewController 在 facebook 和 twitter 上发帖。我的代码是
-(void)postToFacebookWithObject:(id)object FromController:(UIViewController*)vc {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){
if (result == SLComposeViewControllerResultCancelled)
{
DLog(@"Cancelled");
}
else
{
DLog(@"Done");
}
[controller dismissViewControllerAnimated:YES completion:Nil];
};
controller.completionHandler =myBlock;
[controller removeAllImages];
[controller removeAllURLs];
NSMutableDictionary *item = (NSMutableDictionary *)object;
[controller setInitialText:[item objectForKey:@"DealTitle"]];
if([item objectForKey:@"DealImage"])
[controller addImage:[item objectForKey:@"DealImage"]];
if([item objectForKey:@"url"])
[controller addURL:[NSURL URLWithString:[item objectForKey:@"url"]]];
[vc presentViewController:controller animated:YES completion:Nil];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:LocStr(@"NO_FACEBOOK_ACCOUNT_CONFIGURED") delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
DLog(@"UnAvailable");
}
}
这在 ios 7 中工作正常,但在 ios 8 中,这张表出现在我在窗口中添加的视图后面。我该如何解决这个问题?