2012-04-17 142 views
0

我有一個3視圖控制器 - 註冊,登錄,配置文件 和我有一個UISegmentedControl,我可以切換視圖從註冊主要和從登錄到主。 ,但是當我在註冊視圖中的示例id喜歡在完成註冊後將用戶切換到配置文件視圖。切換視圖iphone - 切換到空視圖

enter image description here

enter image description here

和這裏的代碼..

-(IBAction) switchView :(id)sender{ 

switch (segControl.selectedSegmentIndex) { 
    case 0: 
    { 
     HangmanViewController * main =[[HangmanViewController alloc]initWithNibName:nil bundle:nil]; 
     main.modalTransitionStyle = UIModalTransitionStyleCoverVertical; 
     [self presentModalViewController:main animated:YES]; 
     [main release]; 
    } 
     break; 
     case 1: 

      break; 
     case 2: 
    { 
     Profile *profile2 = [[Profile alloc]initWithNibName:nil bundle:nil]; 
     [self presentModalViewController:profile2 animated:YES]; 
     [profile2 release]; 

    }break; 


    default: 
     break; 
} 

}

和我已經進口Profile類的.h文件.. 有啥錯了! !

謝謝。

回答

0

我不明白你的問題完全希望這會幫助你。

 - (IBAction)SegmentControll:(id)sender { 

       if (SegmentControll.selectedSegmentIndex==0) { 

         //your main view 

        } 

       if (SegmentControll.selectedSegmentIndex==1) { 

         //your Profile view 

        } 
     } 
0

是否只有在成功完成註冊/登錄後才能將用戶切換到配置文件視圖否則顯示警報?

,那麼你可以試試這個:在.h文件中

NSString *count; 

在.m文件

@Synthesize count; 

在您的viewDidLoad

[email protected]"1"; 

//所以這裏count的默認值是1

//後成功完成註冊/登錄化妝數= 2

[email protected]"2"; 

在你SegmentControl行動使這種狀況:

- (IBAction)SegmentControll:(id)sender 

      { 

      if (SegmentControll.selectedSegmentIndex==0) 

        { 

       if (count isEqualToString:@"2") { 
       //your main view 
        } 
       else 
       // alert for login/Register 
       } 

      if (SegmentControll.selectedSegmentIndex==1) { 

        //your Profile view 

       } 

     if (SegmentControll.selectedSegmentIndex==2) { 

        //your Register view 

       } 
    }