Question

I got this code that brings up the native "share" view where the user can post to facebook/twitter etc... There is a completion block, but this only get´s called when the VC shows itself, I need to know when it dismisses. Cause my app has different View Controllers for landscape / portrait mode, and I do not want to dismiss the view if the user rotates and the UIACtivityViewController is on screen.

I send a notification when the shared button is pressed to not dismiss the current view if user rotates the device. All i need now, is to know when it´s dismissed so I can reenable the function

- (IBAction)shareButtonPressed:(UIButton *)sender {
    // Notify that another view is on screen to allow rotation without view disapearing.
    [self sendNotificationWithName:@"landscapeViewHasPopupActive" andObject:@"empty string"];

    NSString *message = @"Hello World!";
    UIImage *imageToShare = [UIImage imageNamed:@"Icon.png"];

    NSArray *postItems = @[message, imageToShare];

    UIActivityViewController *activityVC = [[UIActivityViewController alloc]
                                            initWithActivityItems:postItems
                                            applicationActivities:nil];

    [self presentViewController:activityVC animated:YES completion:^() {

    }];
    // Is showing landscape set to NO, and YES when this view disapears
}
Was it helpful?

Solution

In ios6 storyboards, there is a thing called an unwind segue. Add a method to the presenting controller to verify if unwind can/will happen. Check with google.

OTHER TIPS

The same view controller that called the – presentViewController:animated:completion: method has it's counterpart: the – dismissViewControllerAnimated:completion: method.

When you want to dismiss the activityVC controller call the – dismissViewControllerAnimated:completion: method. Use the 'completion' block to execute the code you want when the view controller is dismissed.

Hope this helps!

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