目前没有动画的SKStoreProductViewController

时间:2017-05-10 07:02:46

标签: ios objective-c swift storekit ios-animations

我正在尝试展示SKStoreProductViewController 的实例,而不是动画。

来自视图控制器StoreKit的代码片段来自:

目标C

SKStoreProductViewController *storeProductVC = [[SKStoreProductViewController alloc] init];
[storeProductVC loadProductWithParameters: <PARAMETERS> completionBlock: nil];

[self presentViewController: storeProductVC animated: NO completion: nil];

夫特

let storeProductVC = SKStoreProductViewController()
storeProductVC.loadProduct(withParameters: <PARAMETERS>, completionBlock: nil)

self.present(storeProductVC, animated: false, completion: nil)

传递NO animated标志不起作用。 StoreKit视图控制器仍然显示动画。我知道Apple框架的主题是允许最少的自定义,但我希望情况并非如此。

1 个答案:

答案 0 :(得分:1)

您可以在单独的UIWindow中显示没有动画的内容。

<强>目标C

SKStoreProductViewController *storeProductVC = [[SKStoreProductViewController alloc] init];
[storeProductVC loadProductWithParameters: <PARAMETERS> completionBlock: nil];

UIScreen *mainScreen = [UIScreen mainScreen];

// Note: storeKitWindow should be strongly held, i.e. a property
self.storeKitWindow = [[UIWindow alloc] initWithFrame: mainScreen.bounds];
self.storeKitWindow.screen = mainScreen;
self.storeKitWindow.windowLevel = UIWindowLevelStatusBar;
self.storeKitWindow.rootViewController = storeProductVC;

[self.storeKitWindow makeKeyAndVisible];

<强>夫特

let storeProductVC = SKStoreProductViewController()
storeProductVC.loadProduct(withParameters: [:], completionBlock: nil)

let mainScreen = UIScreen.main

// Note: storeKitWindow should be strongly held, i.e. a property
storeKitWindow = UIWindow(frame: mainScreen.bounds)
storeKitWindow.screen = mainScreen
storeKitWindow.windowLevel = UIWindowLevelStatusBar
storeKitWindow.rootViewController = storeProductVC

storeKitWindow.makeKeyAndVisible()