右侧是选择器视图工具栏按钮“下一步”,并希望通过textFieldShouldReturn
调用其@selector
方法。但它给了我错误Undeclared Selector
。
这是按钮的代码,
UIBarButtonItem *nextBtn = [[UIBarButtonItem alloc] initWithTitle:@"Next" style:UIBarButtonItemStylePlain target:self action:@selector("textFieldShouldReturn here")];
这是我的textFieldShouldReturn方法,
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
self.addScrollView.contentSize = CGSizeMake(320, 1800);
[self.addScrollView setContentOffset:CGPointMake(0, 0 ) animated:NO];
if (textField == industryTxtField) {
[subIndustryTxtField becomeFirstResponder];
}
else if (textField == subIndustryTxtField) {
[address1TxtField becomeFirstResponder];
}
答案 0 :(得分:0)
试试这个......
UIBarButtonItem *nextButton = [[UIBarButtonItem alloc] initWithTitle:@"Next" style:UIBarButtonItemStylePlain target:self action:@selector(moveToNextField)];
-(void)moveToNextField
{
if (industryTxtField.isFirstResponder)
{
[subIndustryTxtField becomeFirstResponder];
}
else if (subIndustryTxtField.isFirstResponder)
{
[address1TxtField becomeFirstResponder];
}
}