English 中文(简体)
添加1名航空控制器,作为主谈的一部分
原标题:adding a uinavigationcontroller to a view as part of a stack of uiviews

In my iphone app, I first call a controller which stack up a few view controllers based on index. This is done cause based on the user s selection, i will need to show different screens (basically, i have a welcome screen, tabbar view - which is the main app, sign in and sign up pages). As of now, everything works perfectly - I stack them up and remove / switch based on the need. The problem is that i would like to add a nav bar to both the sign in and sign up views. However, when i do that, something weird happens - i see a nav bar, but on TOP of it, there is a white bar as well (half width more or less). How can i add this uinavbar successfully?

The controller that is the use of the AppDelegate:

 - (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];

}

当我补充说,对于同一方法中的一位看法控制者,如上所述,它有工作要做。

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

我怎么能做到这一点? 请提供帮助。 感谢!

ADDING MORE INFO ABOUT VIEW WHERE THE KEYBOARD IS BY DEFAULT:

 - (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 = @"example@EMAIL.com";
    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;    
 }
最佳回答

I don t think you should be adding navController.view as a subview to your view controller. I suspect that s a source of the trouble. Instead use a UINavigationBar object.

关于你的第二个问题,如果是个问题,而不是一个话题,那就是,由于你将案文领域1作为第一回应者而出现的关键板。

问题回答

暂无回答




相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

Iphone NSTimer Issue

Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Xcode open two editor windows with same file

Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...

热门标签