iPad:比背景上的隐形按钮更好的方式让用户退出条目?

时间:2010-04-21 14:07:04

标签: iphone ipad

在iPad / iPhone上,你是否还需要在背景上设置一个隐形按钮让用户退出条目?用户在条目外单击时是否有更好的方法来解除键盘?

1 个答案:

答案 0 :(得分:2)

我用

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
在ViewController中

从那里调用活动控件上的resignFirstResponder

//编辑:

我的视图包含多个UITextField;当用户触摸除TextField或键盘之外的任何地方时,我希望键盘消失,所以我的ViewController有这个:

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

这会导致键盘消失。 (我在其他地方跟踪当前的文本字段。)