2011-07-28 11 views
0

私のiPhoneアプリケーションでは、まずインデックスに基づいていくつかのビューコントローラをスタックするコントローラを呼び出します。これは、ユーザーの選択に基づいて行われます、私は別の画面を表示する必要があります(基本的に、私はメイン画面、タブバービュー - メインアプリケーション、サインインし、ページをサインアップしている)。現時点では、すべてが完璧に動作します - 私はそれらを積み重ね、必要に応じてスイッチを切ります。問題は、サインインとサインアップの両方にナビゲーションバーを追加したいということです。しかし、私はそれを行うと、何か変わったことが起こる - 私は、ナビゲーションバーが表示されますが、それの上にも白いバーがあります(半分より多かれ少なかれ)。このuinavbarを正常に追加するにはどうすればよいですか? Iは、上述したように同じ方法でビューコントローラの一つに、それは、仕事をdoesntのことを追加するとuinavigationcontrollerをビューのスタックの一部として追加する

- (void)viewDidLoad 
{ 
[super viewDidLoad]; 

myTabBarVC = [[tabBarController alloc] initWithNibName:@"tabBarController" bundle:nil]; 
[self.view insertSubview:myTabBarVC.view atIndex:0]; 

myLoginVC = [[loginViewController alloc] initWithNibName:@"loginViewController" bundle:nil]; 
[self.view insertSubview:myLoginVC.view atIndex:1]; 

mySignUp = [[SignUpView alloc] initWithNibName:@"SignUpView" bundle:nil]; 
[self.view insertSubview:mySignUp.view atIndex:2]; 

myWelcomeView = [[WelcomeView alloc] initWithNibName:@"WelcomeView" bundle:nil]; 
[self.view insertSubview:myWelcomeView.view atIndex:3]; 

} 

:ここ

はAppDelegateによって呼び出されているコントローラです。

myLoginVC = [[loginViewController alloc] initWithNibName:@"loginViewController" bundle:nil]; 
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:myLoginVC]; 
[self.view insertSubview:navController.view atIndex:1]; 

どうすればいいですか?助けてください。ありがとう!キーボードがデフォルトでオンになっビューの詳細情報ADDING

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

static NSString *CellIdentifier = @"Cell"; 

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if(cell == nil) 
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"]; 

cell.textLabel.text = [[NSArray arrayWithObjects:@"",@"",nil] 
         objectAtIndex:indexPath.row]; 

if (indexPath.row == 0) { 

    textField1 = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 280, 21)]; 
    textField1.delegate = self; 
    textField1.placeholder = @"[email protected]"; 
    textField1.text = [inputTexts objectAtIndex:indexPath.row/2]; 
    textField1.tag = indexPath.row/2; 
    cell.accessoryView = textField1; 
    textField1.returnKeyType = UIReturnKeyNext; 
    textField1.clearButtonMode = UITextFieldViewModeWhileEditing ; 
    [textField1 becomeFirstResponder]; 
    textField1.tag = 1; 

} 
else 
{ 

    textField2 = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 280, 21)]; 
    textField2.delegate = self; 
    textField2.placeholder = @"password"; 
    textField2.text = [inputTexts objectAtIndex:indexPath.row/2]; 
    textField2.tag = indexPath.row/2; 
    textField2.returnKeyType = UIReturnKeyDone; 
    textField2.clearButtonMode = UITextFieldViewModeWhileEditing; 
    cell.accessoryView = textField2; 
    [textField1 becomeFirstResponder]; 
    textField1.tag = 2; 

} 

cell.selectionStyle = UITableViewCellSelectionStyleNone; 
return cell;  
} 

答えて

2

を私はあなたのビューコントローラへのサブビューとしてnavController.viewを追加する必要があるとは思いません。私はそれが問題の原因だと思う。代わりに、UINavigationBarオブジェクトを使用します。

あなたの2番目の質問に関しては、質問であって発言ではない場合、デフォルトではキーボードは最初のレスポンダとしてtextField1を設定しているために起こります。

+0

+1ありがとうございました!全体的にUINavigationBarを使用すると、uinavcontrollerが提供するすべての機能が提供されると思いますか? 2番目の発言に関しては、それは完全に関連していませんが、私はそれらのビューのようにすべてをスタックし、それらのうちの1つが常にキーボードを持っているので、私はアプリを起動すると、どのようにそれを取り除くか分かりません。 – TommyG

+0

あなたが望むことを実行するにはさまざまな方法があります(UINavigationController vs Bar)。キーボードについては、テーブルセルのテキストフィールドを自動的にfirstResponderにするよりも、別のやり方をとると思います。 – onnoweb

関連する問題