gpt4 book ai didi

iphone - UIViewController 子类没有接收到 touchesBegan iphone ipad

转载 作者:行者123 更新时间:2023-12-01 22:44:51 25 4
gpt4 key购买 nike

所以我将 UIViewController 子类化,在 nib 中我有一个 UIView,其中有一个 tableview。据我了解,UIViewController 和 UIView 都是 UIResponder 的子类,因此它们应该接收 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *) 事件方法。

但是,情况并非如此,我的 View Controller 子类没有接收到该方法。如果可以的话,我真的不想子类化 UIView。

我正在尝试实现 this , 但我的

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[textfield resignFirstResponder];
}

没有被调用。

最佳答案

这取决于您触摸的位置。如果您在 TableView 中触摸,触摸将发送到 TableView ,而不是 View Controller 。如果您触摸 View 中的文本字段,触摸将发送到 UITextField 本身。如果您在 tableview 之外、textfield 之外但在 viewcontrollers 的 View 中触摸,那么 view controller 应该获得这些触摸。

关于iphone - UIViewController 子类没有接收到 touchesBegan iphone ipad,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3622483/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com