是否有可能檢測到用戶交互(如滑動滾動型或開始編輯一個文本框),而不使用委託或通知?儘可能使用最基本的觸摸事件。檢測沒有代表
我一直在試圖使用的touchesBegan和touchesEnded但這些並不總是叫。
是否有可能檢測到用戶交互(如滑動滾動型或開始編輯一個文本框),而不使用委託或通知?儘可能使用最基本的觸摸事件。檢測沒有代表
我一直在試圖使用的touchesBegan和touchesEnded但這些並不總是叫。
是的,你可以在IBAction爲只連接到您的UITextField發送的事件 - 編輯而改變,所以每次文本字段改變你的IBAction爲將被調用。編輯開始和編輯結束時可以執行相同的操作。
可以識別觸摸的對象,並執行您所需的操作。
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesBegan:touches withEvent:event];
UITouch *touch = [touches anyObject];
if ([touch.view isKindOfClass: UITextField.class])
{
if (![(UITextField *)touch.view isFirstResponder])
{
//start editing
[(UITextField *)touch.view becomeFirstResponder];
}
}
else
{
}
}
同樣在「touchesEnded」會做。 –
touchesBegan並不總是被調用... – YogevSitton
touchesBegan只會在ViewController類中調用。 –
我想用原來的UIView能力 – YogevSitton
我不知道你有什麼問題,或者你想達到的目標。該方法不需要委託和/或通知。那麼爲什麼你不能做你想做的事呢?你的意思是什麼原創能力? –
@godmoney你想劫持輸入或什麼? – Andy