Я перехожу от раскадровки к UISplitViewController в xib. Я хочу выйти из своего представления раскадровки, что приведет меня к UISplitViewController. В контроллере раскадровки у меня есть UITextField. Я установил его так, чтобы он не закрывался после того, как я нажму Enter. Однако теперь он остается открытым, даже когда я переключаюсь на splitviewcontroller, что мне явно не нужно, потому что я хочу выйти из системы.
Кнопка выхода
UIBarButtonItem *logoutButton = [[UIBarButtonItem alloc] initWithTitle:@"Log Out" style:UIBarButtonItemStylePlain target:self action:@selector(confirmLogout)];
Способ вызвать UISplitViewCOntroller
- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
{
if (alertView.tag==TAG_DEV){
if (buttonIndex) {
[[[UIApplication sharedApplication] delegate] performSelector:@selector(gotoSplitViewController)];
} else {
[self.navigationController popViewControllerAnimated:YES];
}}
}
метод gotoSplitViewController в делегате:
-(void)gotoSplitViewController{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
ListViewController *listVC = [[ListViewController alloc] initWithStyle:UITableViewStylePlain];
UINavigationController *listNC = [[UINavigationController alloc] initWithRootViewController:listVC];
AssignedViewController *assignedVC = [[AssignedViewController alloc] initWithNibName:@"AssignedViewController" bundle:nil];
UINavigationController *assignedNC = [[UINavigationController alloc] initWithRootViewController:assignedVC];
//assign the views to the new nav view controllers
splitViewController = [[UISplitViewController alloc] init];
splitViewController.delegate = assignedVC;
splitViewController.viewControllers = @[listNC, assignedNC];
listVC.detailViewController = assignedVC;
[[self window] setRootViewController:splitViewController];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
}
мой UITextField
self.textBox = [[UITextField alloc] initWithFrame: CGRectMake(10, 660, 750, 90)];
self.textBox.backgroundColor = [UIColor colorWithRed:(209/255.0) green:(236/255.0) blue:(232/255.0) alpha:1];
self.textBox.returnKeyType = UIReturnKeySend;
self.textBox.delegate = self;
[self.view addSubview:self.textBox];
Я пробовал resignFirstResponder в разных местах, включая добавление
- (void)viewWillDisappear:(BOOL)animated
{
[self.textBox resignFirstResponder];
}
Однако ни один из них не работает. Как сделать так, чтобы клавиатура исчезала после смены вида?