Oma*_*mar 4 objective-c storyboard ios
我已经按照教程将In App Purchase添加到我的应用程序中.有2次观看次数:
我已经完全添加了代码,但在教程中他们使用的是XIB文件,但我使用的是Storyboard.我的"购买项目"按钮的代码如下所示:
- (IBAction)PurchaseItem:(id)sender {
_purchaseController = [[PurchasedViewController alloc] initWithNibName:Nil bundle:nil];
_purchaseController.productID = @"com.myapp";
[self presentViewController:_purchaseController animated:YES completion:NULL];
[_purchaseController getProductID:self];
}
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是,当单击按钮时,会出现黑屏,但我希望BuysedViewController显示
我需要改变什么吗?
编辑:
使用已编辑的代码但收到附加错误:
- (IBAction)PurchaseItem:(id)sender {
PurchasedViewController *purchaseContr = (PurchasedViewController *)[self.storyboard instantiateViewControllerWithIdentifier:@"menu"];
//menu is only an example
purchaseContr.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:purchaseContr animated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud)

Ila*_*rio 19
使用故事板,您应该在图片中给出一个标识符:点击您的viewController和"身份检查器"

在此示例中,Custom Class应为: PurchasedViewController
这是代码:
- (IBAction)PurchaseItem:(id)sender {
PurchasedViewController *purchaseContr = (PurchasedViewController *)[self.storyboard instantiateViewControllerWithIdentifier:@"menu"];
//menu is only an example
purchaseContr.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:purchaseContr animated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9606 次 |
| 最近记录: |