0

password首先进入alertView,如果密码不正确,然后另一个alertView显示密码不正确。现在第一个alertView消失了。我想在第一个上显示第二alertViewalertView

4

1 回答 1

2

这不是那么复杂的工作,我只是这样做了:-

UITextField *forgetPass;
-(IBAction)Password{// here is a Action for login password 
    //[txtEmail resignFirstResponder];


    UIAlertView* dialog = [[UIAlertView alloc] init];
    [dialog setDelegate:self];
    [dialog setTitle:@"Enter your password"];
    [dialog setMessage:@" "];
    [dialog addButtonWithTitle:@"Cancel"];
    [dialog addButtonWithTitle:@"OK"];
    dialog.tag= 1;

    forgetPass = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 45.0, 245.0, 25.0)];
    forgetPass.delegate = self;
    [forgetPass setSecureTextEntry:YES];

    forgetPass.placeholder = @"password";
    forgetPass.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
    [forgetPass setBackgroundColor:[UIColor whiteColor]];
    [dialog addSubview:forgetPass];
    CGAffineTransform moveUp = CGAffineTransformMakeTranslation(0.0, 0.0);
    [dialog setTransform: moveUp];
    [dialog show];



}



   -(void) alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex{

    if(alert.tag==1)
    {
    if (buttonIndex == 1) { // OK pushed
        if([forgetPass.text length]>0 )
        {

        }
        else {
            UIAlertView *alert2 = [[UIAlertView alloc]initWithTitle:@"Oops..!" message:@"please enter your current password" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
            UITextField *forgetPass2 = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 45.0, 245.0, 25.0)];
            forgetPass2.delegate = self;
            [forgetPass2 setSecureTextEntry:YES];

            forgetPass2.placeholder = @"password";
            forgetPass2.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
            [forgetPass2 setBackgroundColor:[UIColor whiteColor]];
            [alert2 addSubview:forgetPass2];
            forgetPass2.hidden=YES;
            CGAffineTransform moveUp = CGAffineTransformMakeTranslation(0.0, 0.0);
            [alert2 setTransform: moveUp];


            alert2.tag=2;
            [alert2 show];
            [alert2 release];

        }
    }
    if (buttonIndex == 0)
    {

    }
    }
    else if(alert.tag==2)
    {

        if (buttonIndex == 0)
        {
             [self Password];
        }
    }

}

我只是为您创建了一个演示,可能对您有帮助,请下载:-

http://www.sendspace.com/file/zptg8l

于 2012-11-21T05:48:48.047 回答