我有3节课。
第一个控制器是tabbar中的第一个控制器。我使用presentModalViewController来呈现登录屏幕和主屏幕。我在firstcontrollor中有一个presentModalViewController,它提供登录屏幕,在Loginscreen viewdidload方法中,我有presentModalViewController,它呈现主屏幕。主屏幕presentModalViewController在homePage_Btn_Clicked中被解除,而presentModalViewController在login_Btn_Clicked中被解除。我遇到的问题是我的主屏幕从未出现过。有帮助吗?我是iPhone开发的新手。
//First Controllor
FirstControllor.m
- (void)viewDidLoad
{
[super viewDidLoad];
Accounts_Login *lvc = [[Accounts_Login alloc]initWithNibName:@"Accounts_Login" bundle:[NSBundle mainBundle]];
[self presentModalViewController:lvc animated:NO];
[lvc release];
}
//Login_view class
Login_view.m
- (void)viewDidLoad {
[super viewDidLoad];
Home_Screen *lvc1 = [[Home_Screen alloc]initWithNibName:@"Home_Screen" bundle:[NSBundle mainBundle]];
[self presentModalViewController:lvc1 animated:NO];
[lvc1 release];
user_ID_TextField.text = [[NSUserDefaults standardUserDefaults] objectForKey:@"User ID"];
}
-(IBAction) login_Btn_Clicked{
if ([services authenticate:credential_Data]) {
[self dismissModalViewControllerAnimated:YES];
[credential_Data autorelease];
}
//HomePage class
HomePage.m
-(IBAction) homePage_Btn_Clicked:(id) sender{
UIButton *theButton = (UIButton *)sender;
int count;
switch (theButton.tag) {
case 101:
count++;
[self dismissModalViewControllerAnimated:YES];
break;
default:
break;
}
}
答案 0 :(得分:2)
将presentModalView从viewDidLoad移至viewDidAppear。
答案 1 :(得分:0)
试试这个:
Home_Screen *lvc1 = [[Home_Screen alloc]initWithNibName:@"Home_Screen" bundle:[NSBundle mainBundle]];
[self.parentViewController presentModalViewController:lvc1 animated:NO];
[lvc1 release];