我在這裏有一種情況,我必須爲文本字段處理touchesBegan
。此文本字段處於滾動視圖。在UIScrollView中爲UITextField處理touchesBegan方法
我想這個至今:
我做的UIScrollView
@interface CustomScrollView : UIScrollView
{
}
@end
@implementation CustomScrollView
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"good");
}
@end
下面的一個子類,我可以得到想要的結果。
我用textfields實現了同樣的事情。我做的UITextField
一個子類:
@interface CustomTextField : UITextField
{
}
@end
@implementation CustomTextField
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"good");
}
@end
這工作正常,如果文本字段是一個普通視圖中,但是當文本字段是一個普通的滾動視圖或我的自定義滾動視圖中失敗。
請賜教這個
(我這樣做是爲了達到這樣的事情,當用戶長按在文本框的文本是從文本字段分配一個文本框的標籤,用戶可以在此標籤拖動到其他地方在視圖中)
你救了我的一天;) – DeZigny 2012-07-18 21:43:48