Search code examples
iosios6app-storemodalviewcontroller

Modal App Store won't dismiss


I have a button that shows my app in a modal view, so that people can download and rate the app. I got it to show up modally with this code.

 NSDictionary *appParameters = [NSDictionary dictionaryWithObject:@"607257427"
                           forKey:SKStoreProductParameterITunesItemIdentifier];
     SKStoreProductViewController *productViewController = [[SKStoreProductViewController alloc] init];
    [productViewController setDelegate:self];
    [productViewController loadProductWithParameters:appParameters
                                     completionBlock:^(BOOL result, NSError *error)
    {

    }];
    [self presentViewController:productViewController
                       animated:YES
                     completion:^{

                     }];

`

This is what it turns into.enter image description here

Problem is that the cancel button isn't working, it may be something with the Simulator or also something really simple, but I can't figure out why the cancel button isn't working


Solution

  • You need to implement the delegate method to dismiss the view controller:

    - (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController
    {
        [viewController dismissViewControllerAnimated:YES completion:nil];
    }