在iOS 6中,引入了SKStoreProductViewController以在应用程序中显示iTunes存储项,因此用户不必离开应用程序查看它们。
到目前为止,我还没有找到自定义此视图控制器的导航条的方法。在iOS 6中,它是黑色的,灰色的,在iOS 7中,它是白色的,黑色的。
有什么方法可以改变导航栏的色调吗?( iOS 6和iOS 7)
谢谢。
发布于 2013-09-24 16:56:50
这不是最好的解决方案,但您可以使用UINavigationBar的UIAppearance方法在显示之前设置颜色:
[[UINavigationBar appearance] setTintColor:[UIColor darkGrayColor]];
SKStoreProductViewController *storeProductViewController = [[SKStoreProductViewController alloc] init];
[storeProductViewController setDelegate:self];
[self presentViewController:storeProductViewController animated:YES completion:nil];然后在SKStoreProductViewControllerDelegate方法中,将其更改为以前的.
-(void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController {
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[viewController dismissViewControllerAnimated:YES completion:nil];
}为我工作。
发布于 2013-09-17 01:12:45
很遗憾,我不会。SKStoreProductViewController是一个remote view controller,这意味着它的视图完全由另一个进程拥有,并且无法编程访问。
可以通过查看控制器视图的递归描述来证实这一点:
<UIView: 0x8d48da0; frame = (0 0; 320 480); layer = <CALayer: 0x8d48d70>>
| <_UISizeTrackingView: 0x9b53700; frame = (0 0; 320 480); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x9b53770>>
| | <_UIRemoteView: 0x9b51d70; frame = (0 0; 320 480); transform = [0.5, -0, 0, 0.5, -0, 0]; userInteractionEnabled = NO; layer = <CALayerHost: 0x9b55ae0>>_UIRemoteView表示视图的内容驻留在另一个进程中。
发布于 2014-09-29 08:22:18
我在Appirater rateApp函数中遇到了这个问题,我用这样的方式修复了它:
//Use the in-app StoreKit view if available (iOS 6) and imported. This works in the simulator.
if (!_openInAppStore && NSStringFromClass([SKStoreProductViewController class]) != nil) {
SKStoreProductViewController *storeViewController = [[SKStoreProductViewController alloc] init];
storeViewController.delegate = self.sharedInstance;
NSNumber *appId = [NSNumber numberWithInteger:_appId.integerValue];
[storeViewController loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier:appId} completionBlock:^(BOOL result, NSError *error) {
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
id <AppiraterDelegate> delegate = self.sharedInstance.delegate;
if ([delegate respondsToSelector:@selector(appiraterWillPresentModalView:animated:)]) {
[delegate appiraterWillPresentModalView:self.sharedInstance animated:_usesAnimation];
}
[[self getRootViewController] presentViewController:storeViewController animated:_usesAnimation completion:^{
[self setModalOpen:YES];
//Temporarily use a black status bar to match the StoreKit view.
[self setStatusBarStyle:[UIApplication sharedApplication].statusBarStyle];
[[UIApplication sharedApplication]setStatusBarStyle:UIStatusBarStyleLightContent animated:_usesAnimation];
}];
}];
//Use the standard openUrl method if StoreKit is unavailable.
} else { (...)https://stackoverflow.com/questions/18838727
复制相似问题