2011-07-01 52 views
0

我有3個類。presentModalViewController not responding

第一個控制器是tabbar中的第一個控制器。我正在使用presentModalViewController來顯示登錄屏幕和主屏幕。我有一個presentModalViewController在firstcontrollor中呈現登錄屏幕,並在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

請正確格式化這個代碼! – Pripyat

+0

這是更好嗎? – pa12

+0

粗體不能在代碼塊中工作,所以刪除**。只需使用//評論 – Joe

回答

0

試試這個:

Home_Screen *lvc1 = [[Home_Screen alloc]initWithNibName:@"Home_Screen" bundle:[NSBundle mainBundle]]; 
[self.parentViewController presentModalViewController:lvc1 animated:NO];  
[lvc1 release]; 
+0

不,不起作用。只顯示home_screen,但現在顯示登錄屏幕。它只顯示最新的當前ModalViewController – pa12

+0

您的主屏幕可能會阻止登錄屏幕視圖。嘗試添加:[lvc1.view backgroundColor:[UIColor clearColor]]; – Saikat

+0

單擊按鈕時,我忽視視圖。那麼我認爲這個觀點將會消失nt嗎? – pa12

2

移動presentModalView從viewDidLoad中至viewDidAppear。

+0

它沒有工作。 – pa12

+0

它的工作原理與選定的答案相結合。 – Raptor

相關問題