-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");
        }
    }

私の問題は、ユーザーに2番目のアラート(typeBuyout)を表示した後、ユーザーが選択を行った後、clickedButtonAtIndexが起動しないことです。

viewDidLoadとclickedButtonAtIndexでtypeBuyoutアラートを定義しようとしました[typebuyoutshow]; しかし、同じ結果になります。

4

2 に答える 2

3

デリゲートに自己を与えていない2番目のアラートでは、それをゼロにします。見てみな

于 2013-03-13T13:23:21.457 に答える
2

clickedButtonAtIndexメソッドを呼び出すための2番目のalertviewのデリゲートを設定します

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 に答える