我在显示视图时遇到问题。在当前视图中按下按钮时,将执行以下操作:
- (IBAction) vistaUser: (id)sender{
loginTabController *theInstance = [[loginTabController alloc] init];
[theInstance logIn:user.text :password.text];
}
然后,调用logIn
函数后,必须显示userViewControler
视图,但不显示。查看保持当前状态。但是,userViewController
视图已初始化,并且此视图中的getData
函数已执行!我不明白为什么不显示被叫视图!谢谢你的帮助!
- (void)logIn: (NSString *)strUser: (NSString *)strPass
{
[UIView beginAnimations:@"View Flip" context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
if (self.controladorUser == nil)
{
userViewController *aController = [[userViewController alloc] initWithNibName:@"userViewController" bundle:nil];
self.controladorUser = aController;
[aController release];
}
[UIView setAnimationTransition: UIViewAnimationOptionCurveEaseIn forView:self.view cache:YES];
[self.controladorPass viewWillDisappear:YES];
[self.controladorUser viewWillAppear:YES];
[self.controladorPass.view removeFromSuperview];
[self.view insertSubview:controladorUser.view atIndex:0];
[self.controladorPass viewDidDisappear:YES];
[self.controladorUser viewDidAppear:YES];
[UIView commitAnimations];
//getData call
userViewController *theInstance = [[userViewController alloc] init];
[theInstance getData:strUser :strPass];
}
答案 0 :(得分:1)
您永远不会显示您的loginTabController视图。因此,当您将UserViewController的视图添加到tabViewController的视图时,它不会执行任何操作。试试这个:
- (IBAction) vistaUser: (id)sender{
loginTabController *theInstance = [[loginTabController alloc] init];
[self.view addSubview:theInstance.view];
[theInstance logIn:user.text :password.text];
}
这应该让它工作,但是您可能想要解决一些常见的代码设计问题: