暂停segue直到IAP事务完成

时间:2014-07-04 23:52:06

标签: ios iphone objective-c uiviewcontroller in-app-purchase

当选择purchaseButton时,它会开始购买IAP的过程,这会将用户转移到下一个ViewController

在IAP交易完成之前,我需要弄清楚如何让用户暂停将用户发送到下一个ViewController

有什么建议吗?将根据需要发布任何额外的代码。谢谢!

Segue公司

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.

    if ([segue.identifier isEqualToString:@"leaguesEdit"]) {

        UIButton *button = (UIButton *)sender;
        MREditLeaguesViewController *levc = (MREditLeaguesViewController *)segue.destinationViewController;
        levc.buttonNumber = (int)button.tag;
        NSLog(@"LEVC #: %d", (int)button.tag);
    }
    else if ([segue.identifier isEqualToString:@"nothing"]) {
        // Nothing
    }
}

segueViewController联系在一起。它所在的IBAction是:

- (IBAction)purchase:(id)sender {
    [self purchaseProduct:[validProductsInStore objectAtIndex:0]];
    NSLog(@"IBAction Purchase");

    [self performSegueWithIdentifier:@"leaguesEdit" sender:sender];
}

2 个答案:

答案 0 :(得分:3)

您可以简单地在故事板中连接segue,但是从视图控制器连接到视图控制器。然后,您可以在准备好后以编程方式调用segue:

[self performSegueWithIdentifier:@"leaguesEdit" sender:nil];

答案 1 :(得分:1)

您可以直接从Button中连接和创建segue,而不是从View Controller按钮连接所有这些segue,它位于故事板中的视图下方。在这种情况下,您将有多个segue,它们都不会单独连接到任何控件。您现在可以在实际想要执行segue的位置使用下面的代码行。

[self performSegueWithIdentifier:@"yourSegue" sender:nil];

在故事板中查看视图屏幕下方的黄色按钮。

将segue从该按钮拖放到要连接的View Controller上。当遇到上面的代码行时,prepareForSegue将自动调用。

希望这有帮助。