在iPhone 4中,它正在运行。 但在iPhone 5中,它无法正常工作
为什么不在iPhone 5中工作,任何想法?
在xib文件中,我选择了启用用户交互
-(void)hideKeyboard{
[self.view resignFirstResponder];
}
-(BOOL)textFieldShouldBeginEditing: (UITextField *)textField
{
UIToolbar * keyboardToolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 40)];
keyboardToolBar.barStyle = UIBarStyleDefault;
[keyboardToolBar setItems: [NSArray arrayWithObjects:
[[UIBarButtonItem alloc]initWithTitle:@"First" style:UIBarButtonItemStyleBordered target:self action:@selector(previousTextField)],
[[UIBarButtonItem alloc] initWithTitle:@"Last" style:UIBarButtonItemStyleBordered target:self action:@selector(nextTextField)],
[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
[[UIBarButtonItem alloc]initWithTitle:@"Close" style:UIBarButtonItemStyleDone target:self action:@selector(resignKeyboard)],
nil]];
textField.inputAccessoryView = keyboardToolBar;
}
- (void)nextTextField {
[self hideKeyboard ];
UITextField * txtTeamName = (UITextField *)sender;
[txtTeamName becomeFirstResponder];
}
答案 0 :(得分:0)
-(BOOL)textFieldShouldBeginEditing: (UITextField *)textField
此方法需要BOOL
返回。在此方法的末尾添加return YES;
。