Question

I am using a custom UIActivity to share a picture on a facebook friends wall.

I am using a customViewController in order to display a TableView that lets the user pick the friend to which to share the photo, which I return from the overridden activityViewController method and I call activityDidFinish when the facebook operation has completed, which dismisses my ViewController.

This works fine, but I want to : Dismiss my ViewController after the user presses the button to post to facebook directly and then perform the task asynchronously in the background, so the user can do other stuff in the meantime.

Put more simply : Dismiss the custom ViewController visually before I call activityDidFinish:

So when I press the button I have :

[FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"%@/photos",uid] parameters:postVariablesDictionary HTTPMethod:@"POST" completionHandler:
 ^(FBRequestConnection *connection,
   id result,
   NSError *error)
 {
    if (!error)
    {
        [self activityDidFinish:YES];
    }
    else
    {
        [self activityDidFinish:NO];
    }
 }];

But I would already like to dismiss my ViewControllervisually before that, because in this case we actually have to see if the activity finished or not, for example in the default Facebook activity provided by Apple that posts to your own wall, the ModalViewController is dismissed immediately after you pressed the post button.

Was it helpful?

Solution

Here's a working example:

[Example] http://www.apeth.com/iOSBook/ch26.html#_activity_view

Notice that we end up by calling activityDidFinish:. That is what tears down the original interface. It may be that that is the step you are omitting. If not, just compare what you're doing with what I'm doing, since what I'm doing works (on iPhone).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top