I have followed a tutorial to add In App Purchases to my app. There are 2 views:
I have added the code completely fine but in the tutorial they were using XIB files but I am using Storyboard. My code for the 'Buy item' button looks something like this:
- (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];
}
The issue I have is that when the button is clicked, a black screen appears, but I want PurchasedViewController to show
Do I need to change something?
EDIT:
Using edited code but getting error as attached:
- (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];
}
With a storyboard you should give an Identifier like in the picture: tap on your viewController and in 'identity inspector'
in this example Custom Class should be: PurchasedViewController
and this is the code:
- (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];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With