-5
右側是選取器視圖工具欄按鈕'下一步',並且想通過@selector
在其動作中調用textFieldShouldReturn
方法。但它給我錯誤Undeclared Selector
。 這是按鈕的代碼,如何使用textFieldShouldReturn方法作爲選擇器動作?
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];
}
你有什麼錯誤,按鈕聲明還是函數?你在哪裏調用函數? – gbalduzzi
一旦檢查您打開和關閉了多少個大括號,並且該方法需要返回值(Bool值),那麼您返回了什麼? – raki
按鈕聲明給我警告「Undeclared selector textfieldShouldReturn」 – Harshil