SKStoreProductViewController and GKHostedAuthenticateViewController don't have iPhone landscape modes
Asked Answered
M

2

10

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.

Misdirect answered 13/10, 2012 at 2:3 Comment(2)
I just ran into a similar problem now. I'm making an iPhone app in landscape only mode. Firing up a SKStoreProductViewController to view another iOS app in the store - the SKStoreProductViewController doesn't really look good - there are three tabs that select the contents of the below scrollview. The scrollview does not use the full landscape width which makes it look... half-assed, I don't think there is any other word for it.Greeley
@Greeley and what's more, on the latest ios 7, the skstoreproductviewcontroller actually crashes on landscape modeHouck
B
5

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
Brunei answered 30/5, 2013 at 18:52 Comment(2)
But app crashes on iphone iOS 7. I am stilling looking for the solution.Kid
Me too. Has anyone succeeded in using the SKStoreProductViewController on iOS 7 on landscape app?Ventricle
C
0

Try changing the modalPresentationStyle property on your SKStoreProductViewController before presenting it.

I have had good luck by setting it to UIModalPresentationPageSheet which seems to cover the landscape iPad case pretty well.

Clod answered 10/12, 2014 at 2:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.