Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SKStoreProductViewController and GKHostedAuthenticateViewController don't have iPhone landscape modes

I'm implementing the StoreKit in-app app purchase interface and though it appears that the SKStoreProductViewController handles landscape on iPad, it does not appear to do so for my app on iPhone (it's universal).

The interface to SKStoreProductViewController is so limited, I don't appear to be able to manipulate the VC in any way. Has anyone else run into this? Any work-arounds?

When I run the code that works on iPad, the SKStoreProductViewController comes in from the left side, about an inch, and hangs out there until dismissed. It seems functional, but it messes up the VC that popped it up upon dismissal.

Here's the code:

// Set up the store vc (creating it if not already done)
if (self.storeVC == nil) self.storeVC = [[SKStoreProductViewController alloc] init];
self.storeVC.delegate = self;
NSDictionary *params = [NSDictionary dictionaryWithObject:appID forKey:SKStoreProductParameterITunesItemIdentifier]; 

// Set up a HUD in case connecting to the store takes a while
[MBProgressHUD showHUDAddedTo:self.view animated:YES]; 

[self.storeVC loadProductWithParameters:params
                        completionBlock:^(BOOL result, NSError *error) {
       [MBProgressHUD hideHUDForView:self.view animated:YES];
       if (result) {
           [self presentViewController:self.storeVC animated:NO completion:^{
           }];
       }
  }];

Even better, we're having the same problem on the GKHostedAuthenticateViewController which is the viewcontroller returned from the method:

GKLocalPlayer.authenticateHandler = ^(UIViewController *loginVC, NSError *error) {};

To reiterate: both of these are in portrait mode on iPhones (but not iPads) and they force the UI to go into portrait mode. Upon returning, your app's UI is messed up.

like image 594
Gabriel Adauto Avatar asked Oct 13 '12 02:10

Gabriel Adauto


People also ask

How do I get my iPhone to landscape?

Swipe down from the top-right corner of your screen to open Control Center. Tap the Portrait Orientation Lock button to make sure that it's off.

Why is my keyboard sideways on Facebook?

Go to General > Accessibility > AssistiveTouch. Make sure the toggle at the top of the screen is in the On position. Tap one of the four options (Single Tap, Double Tap, Long Press, or 3D Touch) and set it to Open Menu.


1 Answers

I ran into a similar problem. My universal app is in landscape, but while the SKStoreProductViewController works fairly well in landscape on the iPad, it presents with visual glitches on the iPhone.

My solution was to force the iPhone to present the SKStoreProductViewController in portrait. It's a little sad that it doesn't have the same orientation as the rest of the app, but it's better than having half the screen cut off.

I accomplished this by using the custom subclass below:

@interface SKPortraitStoreProductViewController : SKStoreProductViewController
@end

@implementation SKPortraitStoreProductViewController
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
        return UIInterfaceOrientationPortrait;
    else
        return [super preferredInterfaceOrientationForPresentation];
}
@end
like image 92
Edward Marks Avatar answered Oct 24 '22 12:10

Edward Marks