2010-03-30 90 views
2
-(BOOL) textFieldShouldReturn:(UITextField*) theTextField{ 
    [theTextField resignFirstResponder]; 
    return YES; 
} 

它是不工作的数字键盘....如何解雇返回键

回答

3

This answer证明委托来决定是否关闭该键盘。

如果你想关闭该键盘,textFieldShouldReturn:必须返回NO:

-(BOOL) textFieldShouldReturn:(UITextField*) theTextField{ 
    [theTextField resignFirstResponder]; 
    return NO; 
} 
+1

这似乎不再为数字键盘工作的iOS 7.1的方法不会被调用如果键盘类型是数字键区,但如果它是默认的键盘类型的话。 – james2code 2014-04-04 19:33:37