我是iPhone开发的新手。我将学习创建一个用户需要登录的页面。如果用户凭据正确,则应允许他/她进入应用程序中的下一页。
任何帮助将不胜感激。
提前致谢。
答案 0 :(得分: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];
}
}
答案 1 :(得分: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
希望这能帮到你... :)