-5

我是 iPhone 开发的新手。我将学习创建一个用户需要登录的页面。如果用户凭据正确,则应允许他/她进入应用程序的下一页。

任何帮助将不胜感激。

提前致谢。

4

2 回答 2

3

在这里,我们调用执行选择器 sentAuthenticateDetails 来进行 Web 服务身份验证。

-(IBAction)login_Button_Clicked:(id)sender  
{ 

    [currentTextField resignFirstResponder];
    BOOL allFieldsSuccess;

    if((![self.userNameOrEmail_Str length]>0)||(![self.password_Str length]>0)) 
    {
        UIAlertView *alertView=[[UIAlertView alloc]initWithTitle:@"for Login" message:@"Please enter proper Userid & Password" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
        [alertView show];
        [alertView release];
        NSLog(@"no values");
        allFieldsSuccess = NO;
        return;

    }
    else
    {
      allFieldsSuccess = YES;  
    }

    if (allFieldsSuccess==YES)// && (emailSuccess==YES))
    {

        [self.spinner startAnimating];

        [self performSelector:@selector(sentAuthenticateDetails) withObject:nil afterDelay:0.2];
    }   
}
于 2012-06-22T09:56:32.007 回答
1

在您的登录按钮上给出以下方法...

-(IBAction)onClickLogin:(id)sender
{
    if ([txtUserName.text isEqualToString:@""]) 
    {
        ///here paste your Alert View with message:@"Please Fill Up Email and Password"
    }
    else if([txtPassWord.text isEqualToString:@""])
    {
        ///here paste your Alert View with Message message:@"Please Fill Up Email and Password"        
    }
    ///if here you use web-service for store the user data then give the request with username and password also
    if([txtUserName.text isEqualToString:storeduserName] && [txtPassWord.text isEqualToString:storedpassWord]
    {
       yourViewController *objviewController = [[yourViewController alloc] initWithNibName:@"yourViewController" bundle:nil];
       [self.navigationController objviewController animated:YES];
    }
   else
   {
        ///Alert with username or password is incorrect try again
   }
}

还检查下面的演示...

https://github.com/ijoshsmith/iOSLogin

希望这可以帮助你...... :)

于 2012-06-22T09:33:57.987 回答