我要在 xib 中从情节提要到 UISplitViewController。我想注销我的故事板视图,这将把我带到 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];
}
但是,它们都不起作用。视图更改后如何让键盘消失?