我需要在用户记录ID后加载视图。要确定用户名和密码组合的脚本是否正确,我有以下代码:
-(IBAction)buttonClicked:(id)sender {
NSURL *url = [NSURL URLWithString:@"................."];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request addPostValue:gebruikersnaam.text forKey:@"gebruikersnaam"];
[request addPostValue:wachtwoord.text forKey:@"wachtwoord"];
[request setDelegate:self];
[request setDidFinishSelector:@selector(requestFinished:)];
[request setDidFailSelector:@selector(requestFailed:)];
[request startSynchronous];
NSString *toegang = [NSString stringWithFormat:@"%@", [request responseString]];
int level = [toegang intValue];
if(level == 0){
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Inloggen mislukt!" message:@"Het inloggen met het opgegeven gebruikersnaam en wachtwoord is mislukt. Probeer het opnieuw" delegate:self cancelButtonTitle:@"Probeer Opnieuw" otherButtonTitles:nil];
[alert show];
[alert release];
} else {
[self.view removeFromSuperview];
}
}
如何在else {语句中触发另一个视图?我需要在用户登录时加载视图,而不是在应用程序启动时加载..
答案 0 :(得分:0)
如果您以编程方式定义视图,则可以使用:
MyUIView* subview = [[[MyUIView alloc] initWithFrame:CGRectMake(...)] autorelease];
[self.view addSubview:subview];
如果您需要更多帮助,请说明您希望如何定义UIView
。