-1

在我的应用程序中,我有按钮,允许用户购买当前商品。

我希望用户确认,他接受销售协议,然后他选择他的首选付款方式。

我的逻辑如下。

用户点击购买按钮后,会弹出如下 UIAlertView:

NSMutableString *msg = [[NSMutableString alloc] initWithFormat:@"By recognizing this agreement you agree, that in following 15 minutes you will pay for %@ which has price of %@, if you won't make the payment, your account may be blocked for this item.",mainTitle.text,buyoutPrice.text];
    UIAlertView *buyoutAlert = [[UIAlertView alloc] initWithTitle:@"Buyout" message:msg
                                                       delegate:self cancelButtonTitle:@"I don't agree" otherButtonTitles:@"I agree",nil];
    buyoutAlert.tag = 1;
    [buyoutAlert show];

在我的 - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
我正在检查他是否接受......

        - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    if(alertView.tag == 1)
        {
            if(buttonIndex == 1)
            {
                UIAlertView *typeBuyout = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Anonymous payment", nil)
                                                       message:NSLocalizedString(@"Do you wish to make payment as anon?", nil)
                                                      delegate:nil
                                             cancelButtonTitle:NSLocalizedString(@"Cancel", nil)
                                             otherButtonTitles:@"Anon buyout",@"Regular buyout",nil];
                typeBuyout.tag = 2;

                [typeBuyout show];

            }
        }


if(alertView.tag == 2)
{

        if(buttonIndex == 1)
        {
            //anon
            NSLog(@"anon");
        }else if(buttonIndex == 2)
        {
            //normal 
            NSLog(@"Normal");
        }
    }

我的问题是,在向用户显示第二个警报(typeBuyout)并且在用户做出他的选择之后 clickedButtonAtIndex 不会触发。

我试图在 viewDidLoad 和 clickedButtonAtIndex 中定义我的 typeBuyout 警报 [typebuyout show]; 但结果相同。

4

2 回答 2

3

在第二个警报中,您没有提供委托自我,而是将其设为零。一探究竟

于 2013-03-13T13:23:21.457 回答
2

设置第二个警报视图的委托以调用clickedButtonAtIndex方法

if(buttonIndex == 1)
 {
            UIAlertView *typeBuyout = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Anonymous payment", nil)
                                                   message:NSLocalizedString(@"Do you wish to make payment as anon?", nil)
                                                  delegate:self
                                         cancelButtonTitle:NSLocalizedString(@"Cancel", nil)
                                         otherButtonTitles:@"Anon buyout",@"Regular buyout",nil];
            typeBuyout.tag = 2;

            [typeBuyout show];

        } 
于 2013-03-13T13:21:04.733 回答