Skip to content

Instantly share code, notes, and snippets.

@takuhou
Created February 26, 2015 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takuhou/553219be5304ccbb8a2a to your computer and use it in GitHub Desktop.
Save takuhou/553219be5304ccbb8a2a to your computer and use it in GitHub Desktop.
アプリ内にAppStoreをだいたい半分だけ表示してみる ref: http://qiita.com/takuhou/items/46571c310708b4033784
#import <UIKit/UIKit.h>
#import <StoreKit/StoreKit.h>
@interface ViewController : UIViewController {
// AppStore表示用のViewController
SKStoreProductViewController *productViewController;
}
@end
#import "ViewController.h"
@interface ViewController () <SKStoreProductViewControllerDelegate>
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
productViewController = [[SKStoreProductViewController alloc] init];
productViewController.delegate = self;
self.modalPresentationStyle = UIModalPresentationFormSheet;
}
- (void)viewDidAppear:(BOOL)animated
{
[self presentViewController:productViewController animated:YES completion:^() {
NSString *productID = @"646680221";
NSDictionary *parameters = @{SKStoreProductParameterITunesItemIdentifier:productID};
[productViewController loadProductWithParameters:parameters
completionBlock:^(BOOL result, NSError *error)
{}];
}];
self.view.superview.frame = CGRectMake(0, 300, 320, 180);
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController {
[self dismissViewControllerAnimated:YES completion:nil];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment