我有一個UIViewController,它包含一個UIScrollView,它的contentview內有一個UIView。爲什麼我的UIViewController不響應觸摸?
我有下面的代碼不能正常工作,鍵盤沒有被駁回,爲什麼?:
#pragma mark -
#pragma mark Touch Events
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
if ([touch view] == scrollView || [touch view] == self.view)
{
[usernameTextField resignFirstResponder];
[passwordTextField resignFirstResponder];
}
}
你是否將textfield委託設置爲self? –