Created
February 26, 2015 13:38
-
-
Save takuhou/553219be5304ccbb8a2a to your computer and use it in GitHub Desktop.
アプリ内にAppStoreをだいたい半分だけ表示してみる ref: http://qiita.com/takuhou/items/46571c310708b4033784
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
#import <StoreKit/StoreKit.h> | |
@interface ViewController : UIViewController { | |
// AppStore表示用のViewController | |
SKStoreProductViewController *productViewController; | |
} | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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