0

I have a button at the end of a guide that says Done!I need it to bring up Facebook posting dialogue and also segue back to the menu screen

At the moment I have it opening a Facebook posting screen, which pops up and goes back down when you click post or cancel. I would like it to return to the menu after the facebook process has completed. I have followed a guide on how segue programatically and have added the code to my current postToFacebook IBAction but it didn't work. I then tried to create it's own IBAction and link it to the button but it didnt work either. Does anyone know how I can get it to segue after the Facebook dialogue Heres my code for facebook posting in case you need it

- (IBAction)PostToFacebook:(id)sender {
mySLComposerSheet = [[SLComposeViewController alloc] init];
mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[mySLComposerSheet setInitialText:@"I just followed a guide on this App - Get it on the App Store http://"];
[self presentViewController:mySLComposerSheet animated:YES completion:nil];
}

And heres the code for the programatic segue

-(IBAction)nextView{
[self performSegueWithIdentifier:@"next" sender:self];   }
4

2 回答 2

0

您可以将所有代码放在一个中-(IBAction),并使用一个布尔值,在执行 facebook 操作后更改它的值。

像这样的东西,

- (IBAction)PostToFacebook:(id)sender {
    if(valueOfBoolean==TRUE){
        mySLComposerSheet = [[SLComposeViewController alloc] init];
        mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
        [mySLComposerSheet setInitialText:@"I just followed a guide on this App - Get it on the App Store http://"];
        [self presentViewController:mySLComposerSheet animated:YES completion:nil];
        valueOfBoolean=FALSE;
    }
    else{
        [self performSegueWithIdentifier:@"next" sender:self];
    }
}

在方法valueOfBoolean中设置默认值。TRUEviewDidLoad

于 2013-09-10T08:28:37.293 回答
0

编辑:

   - (IBAction)facebook:(id)sender {


    if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
        SLComposeViewController *facebook = [[SLComposeViewController alloc]init];

        facebook = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
        [facebook setInitialText:[NSString stringWithFormat:@"your string"]];
        [self presentViewController:facebook animated:YES completion:nil];

        [facebook setCompletionHandler:^(SLComposeViewControllerResult result){
            NSString *output;
            switch (result) {
                case SLComposeViewControllerResultCancelled:
                    // here you can handle your seque, or your custom action what you want
                    break;
                case SLComposeViewControllerResultDone:
                    // here you can handle your seque, or your custom action what you want
                    break;
                default:
                    break;
            }
            //            [self dismissViewControllerAnimated:YES completion:nil];

        }];
    }
    else{
        UIAlertView * alertView = [[UIAlertView alloc]initWithTitle:@"No Facebook Account" message:@"There are no Facebook accounts configured. You can configure or create accounts in settings ." delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
        [alertView show];
    }

}

我希望它有帮助!

于 2013-09-10T08:33:52.187 回答