0

これが私のコードです:

- (IBAction)login:(id)sender {
    UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Login"
                                                      message:@"Enter your username & password"
                                                     delegate:self 
                                            cancelButtonTitle:@"Cancel" 
                                            otherButtonTitles:@"Login", nil];

    [message setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];

    [message show];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    NSString *title = [alertView buttonTitleAtIndex:buttonIndex];

    if([title isEqualToString:@"Login"])
    {
        UITextField *username = [alertView textFieldAtIndex:0];
        UITextField *password = [alertView textFieldAtIndex:1]; 
    }
}
4

2 に答える 2

0

ユーザー名とパスワードを確認したら --

[self performSegueWithIdentifier:@"LoginSegue" sender:self];

ログイン情報を取得するコントローラーから、ログイン後に表示したいコントローラーへの「LoginSegue」をストーリーボードに作成します。

于 2013-07-18T22:18:05.090 に答える
0

2 つのプロパティ (userName と Password) を持つ目的の c クラスを作成します。次に、コードを変更します。

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

           NSString *title = [alertView buttonTitleAtIndex:buttonIndex];

           if([title isEqualToString:@"Login"]) { 

                UITextField *username = [alertView textFieldAtIndex:0]; 
                UITextField *password = [alertView textFieldAtIndex:1];

Validate your password and user name using **username.text and password.text**

if its valid then

                //create an Object the for the class which holds UserName and Password and set the values.
                newObj.userName = username.text;
                newObj.password = password.text;

               pass the object from here where you want'
               release the newObj
        } 
    }
于 2012-07-16T04:42:32.960 に答える