10

我正在实现 StoreKit 应用内应用购买界面,虽然它似乎是SKStoreProductViewControlleriPad 上的手柄景观,但对于我在 iPhone 上的应用似乎并没有这样做(它是通用的)。

界面SKStoreProductViewController非常有限,我似乎无法以VC任何方式操作。 有没有其他人遇到过这个?任何变通办法?

当我运行在 iPad 上运行的代码时,SKStoreProductViewController它从左侧进来,大约一英寸,然后一直挂在那里直到被解散。它看起来很实用,但它弄乱了在解雇时弹出它的 VC。

这是代码:

// 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:^{
           }];
       }
  }];

更好的是,我们在GKHostedAuthenticateViewController哪个是从方法返回的视图控制器上遇到了同样的问题:

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

重申一下:这两个都在 iPhone(但不是 iPad)上处于纵向模式,并且它们强制 UI 进入纵向模式。返回后,您的应用程序的用户界面就混乱了。

4

2 回答 2

5

我遇到了类似的问题。我的通用应用程序是横向的,但是虽然 SKStoreProductViewController 在 iPad 上的横向工作得相当好,但它在 iPhone 上会出现视觉故障。

我的解决方案是强制 iPhone 以纵向显示 SKStoreProductViewController。有点遗憾,它与应用程序的其余部分没有相同的方向,但总比截掉一半屏幕要好。

我通过使用下面的自定义子类实现了这一点:

@interface SKPortraitStoreProductViewController : SKStoreProductViewController
@end

@implementation SKPortraitStoreProductViewController
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
        return UIInterfaceOrientationPortrait;
    else
        return [super preferredInterfaceOrientationForPresentation];
}
@end
于 2013-05-30T18:52:43.123 回答
0

在展示之前尝试更改modalPresentationStyle您的属性。SKStoreProductViewController

UIModalPresentationPageSheet通过将其设置为似乎可以很好地覆盖横向 iPad 外壳,我已经很幸运了。

于 2014-12-10T02:02:29.643 回答