Tag: first responder

UIView自动移动uitextfield键盘

所以我手上有一个很奇怪的问题,search时间一点也不提供。 我有一个包含uitextfield的uview。 现在最初这个视图在可见屏幕之外,坐标如x = -500,y = -500。 但是,按一个button按下此视图animation并移动到屏幕的中心。 现在,每当我点击这个视图的子视图的uitextfield时,这个视图就会移回到它在屏幕之外的原始坐标。 我疯狂地检查了我的代码,没有任何东西在外面再次移动视图。任何帮助解释这个非常陌生的行为将非常感激。 该代码将视图移动到屏幕上 – (IBAction)Register:(id)sender { //(self.view.frame.size.width/2)-(self.SignUp_Screen.frame.size.width/2); //self.login_Screen.hidden = YES; self.blurView.hidden = NO; //self.SignUp_Screen.layer.zPosition = 5; NSLog(@"Register"); self.SignUp_Screen.hidden = NO; [UIView animateWithDuration:0.25 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ self.SignUp_Screen.frame = CGRectMake(35, 50,self.SignUp_Screen.frame.size.width , self.SignUp_Screen.frame.size.height); } completion:^(BOOL finished) { }]; } 这些是textfield的委托方法 -(void)textFieldDidEndEditing:(UITextField *)textField { NSLog(@"TextFieldEndEditing"); [textField resignFirstResponder]; } -(BOOL)textFieldShouldReturn:(UITextField *)textField […]

无法将searchBar设置为firstResponder

我有一个searchBar我设置在一个tableviewcontroller。 我已经引用了这个类似的问题UISearchBar不能成为UITableView重新出现后的第一响应者,但仍然无法将其设置为第一响应者。 在.h文件中: @property (strong, nonatomic) UISearchController *searchController; @property (strong, nonatomic) IBOutlet UISearchBar *searchBar; 鉴于didload: self.searchController = [[UISearchController alloc]initWithSearchResultsController:nil]; self.searchController.searchResultsUpdater = self; self.searchController.dimsBackgroundDuringPresentation = NO; self.searchController.hidesNavigationBarDuringPresentation = NO; self.searchController.searchBar.frame = CGRectMake(self.searchController.searchBar.frame.origin.x, self.searchController.searchBar.frame.origin.y, self.searchController.searchBar.frame.size.width, 44.0); self.tableView.tableHeaderView = self.searchController.searchBar; 而在viewDidAppear: -(void)viewDidAppear:(BOOL)animated { [self.searchController setActive:YES]; [self.searchController.searchBar becomeFirstResponder]; [super viewDidAppear:animated]; } 当我继续观看searchBaranimation,但没有出现键盘。