0

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.

Tibor Udvari
  • 2,932
  • 3
  • 23
  • 39

1 Answers1

0

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).

user1673099
  • 3,293
  • 7
  • 26
  • 57
  • Thanks for the input. But I feel that you didn't completely understand my problem. When the user clicks on the button "Post to a friends wall" the operation might take 2-3 seconds to complete, and that's when I can say that if it had an error or not and call activityDidFinish:YES or NO appropriately. In those 2-3 seconds the my custom ViewController is still showing; which is the part I don't want. Say in your example in the doDone: method you would have an operation that would be time consuming, you would want to dimiss the View directly and then return if it finished correctly or not ... – Tibor Udvari Sep 19 '13 at 09:28