我正在实施StoreKit应用内购买界面,虽然看起来SKStoreProductViewController
处理iPad上的风景,但我的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
上遇到了同样的问题,即从该方法返回的viewcontroller:
GKLocalPlayer.authenticateHandler = ^(UIViewController *loginVC, NSError *error) {};
重申一下:这两种都是在iPhone(但不是iPad)上处于纵向模式,它们迫使用户界面进入纵向模式。返回后,您应用的用户界面搞砸了。
答案 0 :(得分: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
答案 1 :(得分:0)
在展示之前尝试更改modalPresentationStyle
上的SKStoreProductViewController
属性。
我把它设置为UIModalPresentationPageSheet
,好运,这似乎很好地涵盖了iPad的风景。