我试着用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中,这张纸就在我的视图后面,我在窗口上添加了它。我怎么才能解决这个问题?

发布于 2014-10-11 11:23:45
我通过在navigationcontroller.view上而不是在窗口上添加我的视图来解决这个问题。
发布于 2014-10-29 14:01:45
UINavigationController *forShare = [[UINavigationController alloc] initWithRootViewController:vc];
[forShare setNavigationBarHidden:YES];
[self presentViewController:forShare animated:NO completion:nil];如果是动画:是的,如果是动画,它就不工作:不,它适用于我
发布于 2015-01-19 07:49:25
I have resolved through open present-view controller in navigation-bar.it may help you.
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controller setInitialText:shareFrom];
[controller addImage:self.photoImageView.image];
[controller addURL:[NSURL URLWithString:dayCareWebsite]];
dispatch_async(dispatch_get_main_queue(), ^ {
[self.navigationController presentViewController:controller animated:YES completion:nil];
});https://stackoverflow.com/questions/26115549
复制相似问题