shadow screen occur with Social Framework on iOS - iphone

I create application with feature 'shared with facebook'
I use this code for make a facebook sharing
[facebookViewController setInitialText:[NSString stringWithFormat:#"via %#", self.randomGame.name]];
NSLog(#"%#", self.resultImageView.image);
[facebookViewController addImage:self.resultImageView.image];
[facebookViewController setCompletionHandler:^(SLComposeViewControllerResult result){
if (result == SLComposeViewControllerResultCancelled) {
NSLog(#"Dialog Did Cancel");
}
}];
[self presentViewController:facebookViewController animated:YES completion:nil];
I already have allocation/initialization facebookViewController object with SLComposeViewController.
first time I share there is no problem.
But, I share second time I get a shadow screen like this
can anyone help ?
Thanks for advance.

i am not sure but every time you present the facebook popover you also need to dismiss it in the completion block like
[facebookViewController dismissViewControllerAnimated:YES completion:Nil];
hope it helps

I done it with code
facebookViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[facebookViewController setInitialText:[NSString stringWithFormat:#"via %#", self.randomGame.name]];
[facebookViewController addImage:self.resultImageView.image];
[self presentViewController:facebookViewController animated:YES completion:nil];

Related

SLServiceTypeFacebook in SLComposeViewController hang my iphone app

I have implemented Facebook sharing in my app. But When composerview is opened and i tapped on post, after that it will block my app. I am not able to navigate to other view controller. Here is the code that i have used:
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){
if (result == SLComposeViewControllerResultCancelled) {
} else {
}
[controller dismissViewControllerAnimated:YES completion:Nil];
};
controller.completionHandler = myBlock;
[controller setInitialText:strMsg];
[vc presentViewController:controller animated:YES completion:Nil];
I faced the same issue and debugged as well. In my case it was not a hang; after the SLCompeseViewController disappeared (moved up the screen) there were some UIViews, UIControls remaining on the controller.view which hinder user interaction (i think it is the same in your app).
If it is the same case, you will never be able to remove those Views because the completion handler is never called.
This is a bug in iOS8, here is the link.
https://developers.facebook.com/bugs/962985360399542/?search_id
I suggest you to use UIActivityViewController instead of SLComposeViewController.

presentViewController doesn't do anything

I have a method called:
- (NSDictionary *)requestCompleted:(ASIHTTPRequest *)request{
As you probably guessed, it starts when i get a request back from a web server.
My issue is that the next command runs, but doesn't do anything…
[self presentViewController:loadingPageVC animated:YES completion:nil];
I feel like I forgot to init something but I can't anything wrong.
try this
dispatch_async(dispatch_get_main_queue(), ^{
[self presentViewController:loadingPageVC animated:YES completion:nil];
});

iOS - dismissing a facebook window do not fires dismissViewController completion block

I have this code compiled and running for iOS 6.
SLComposeViewController *control = [SLComposeViewController composeViewControllerForServiceType:...];
[control setInitialText:...];
[control addURL:...];
[control setCompletionHandler:^(SLComposeViewControllerResult result) {
[self dismissViewControllerAnimated:YES completion:^{
// do something
}];
}];
[self presentViewController:control animated:YES completion:nil];
if this is used as a Twitter control, it works fine, but if it is used as a Facebook control, the completion block of the dismissViewController is not called, ever!!! (the doSomething part never runs).
I thought this could have something to do with the controller being dismissed not on the main thread, so I have changed that to
dispatch_async(dispatch_get_main_queue(), ^{
[self dismissViewControllerAnimated:YES completion:^{
// do stuff...
}];
});
without success.
Is this an iOS 6 bug? how do I solve that?
this is the solution:
[self dismissViewControllerAnimated:YES completion:nil];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.6 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
// do stuff
});
this is probably an iOS 6 bug related to the dismissViewController API.
EDIT: I have created a more powerful solution and posted here

iOS - Posting to Facebook... is the icon this one?

I am posting to Facebook using the social api of iOS 6.
I am using the tradicional SLComposeViewController, like in..
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
...
at some point I do
[controller addImage:imageFacebook];
where imageFacebook is a screenshot that is 280 pixels high and then I post to Facebook.
My problem is this. I am following similar approach with the twitter API, but when that little window shows, there is a thumbnail of the image I am sending, hold by a clips on the right side, but on the facebook counterpart I see this safari-like icon. Is this normal? I would be a happy man if I was seen here a miniature of the image being posted, as I saw with the twitter API...
NOTE: the image is being posted correctly to Facebook... my problem is this icon on the posting window.
Is there a way to change that icon?
thanks
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){
if (result == SLComposeViewControllerResultCancelled) {
NSLog(#"Cancelled");
} else {
NSLog(#"Done");
}
[controller dismissViewControllerAnimated:YES completion:Nil];
};
controller.completionHandler = myBlock;
[controller setInitialText:#"Enter Your Text Here:"];
[controller addURL:[NSURL URLWithString:#"http://www.google.com"]];
[controller addImage:[UIImage imageNamed:#"image001-794043.jpeg"]];
[self presentViewController:controller animated:YES completion:Nil];
} else {
NSLog(#"UnAvailable");
}

Twitter Post iOS6 'Cancel' button issue

I'm in the process of changing my app for iOS6 and iPhone use, I can't seem to figure out why when I post from Twitter using the new Social framework I have to press 'Cancel' twice to close, anybody else have this issue or a fix? Here is the code for the button.
- (IBAction)twitterPost:(id)sender
{
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{
mySLComposerSheet = [[SLComposeViewController alloc] init];
mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[mySLComposerSheet setInitialText:[NSString stringWithFormat:#"This is my tweet, hello!",mySLComposerSheet.serviceType]];
[self presentViewController:mySLComposerSheet animated:YES completion:nil];
}
[mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
NSLog(#"dfsdf");
switch (result) {
case SLComposeViewControllerResultCancelled:
break;
case SLComposeViewControllerResultDone:
break;
default:
break;
}
}];
}
If your using the mySLComposerSheet this works great...
[mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
[mySLComposerSheet dismissViewControllerAnimated:YES completion:nil];
My experience with SLComposeViewController is that twitter and weibo controllers need to be dismissed manually while the facebook controller seems to be better behaved.
If I don't dismissViewControllerAnimated myself, tapping the "Send" button will send the tweet or weibo posting but I'll be left with what seems to be an invisible view over my own view. Thus I can no longer interact with my app.
I don't know why my app is working like this... Interestingly, the completionHandler for cancel gets called just once. The second tap dismisses the view controller.
+ (void) shareText:(NSString*)text image:(UIImage*)image social:(NSString*)service url:(NSString*)url
{
SLComposeViewController* controller = [SLComposeViewController composeViewControllerForServiceType:service];
[controller setInitialText:text];
[controller addImage:image];
[controller addURL:[NSURL URLWithString:url]];
controller.completionHandler = ^(SLComposeViewControllerResult result) {
if( SLComposeViewControllerResultDone == result )
{
NSLog(#"rewards for share: %#!", service );
}
if( ![SLServiceTypeFacebook isEqualToString:service] ) // facebook behaves
[[CBLAppDelegate instance].activeViewController dismissViewControllerAnimated:true completion:nil];
};
[[CBLAppDelegate instance].activeViewController presentViewController:controller animated:true completion:nil];
}
Found the issue. It only happens when a completion handler is added to TWTweetComposeViewController. If added, make sure to call:
[self dismissModalViewControllerAnimated:YES];
Try this buddy
[mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
switch (result) {
case SLComposeViewControllerResultCancelled:
[self performSelector:#selector(showalert)];
[mySLComposerSheet dismissViewControllerAnimated:YES completion:nil];
break;
case SLComposeViewControllerResultDone:
[self performSelector:#selector(showalert1)];
[mySLComposerSheet dismissViewControllerAnimated:YES completion:nil];
break;
default:
break;
}
}];
Posting comment above as an answer:
Have you tried setting the completionHandler before presenting the View Controller?