當前項目在cocos2d v2下運行。以編程方式調用textFieldShouldReturn
我有一個簡單的UITextField添加到CCLayer。
每當用戶觸摸textField時,都會出現一個鍵盤。
然後當用戶觸摸「返回」按鈕時,鍵盤消失並清除輸入。
我試圖做的是在用戶觸摸UITextField外的任何地方時做同樣的事情。
我沒有找到一個方法,它的工作原理:
- (void)ccTouchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
UITouch* touch = [touches anyObject];
if(touch.view.tag != kTAGTextField){
[[[[CCDirector sharedDirector] view] viewWithTag:kTAGTextField] resignFirstResponder];
}
}
然而,這種方法不調用該函數:
- (BOOL)textFieldShouldReturn:(UITextField *)textField
我用這個功能做了一些計算和清除輸入。因此,當文本字段爲「resignFirstResponder」時,我希望ccTouchesBegan輸入此文本字段應該返回。
BabyAzerty你有沒有找到一種方法如何做到這一點? – Ramis 2016-02-01 14:07:57