How to hide Textbox Keyboard when “Done / Return” Button is pressed Xcode 4.2

前端 未结 3 1185
孤街浪徒
孤街浪徒 2021-01-30 12:52

I created a Text Field in Interface Builder. I set it\'s \"Return Key\" to Done. This is a one line only input (so it wont need multiple lines).

How do I hide the virt

3条回答
  •  抹茶落季
    2021-01-30 13:19

    Make category on UIViewController with next method

    - (void)hideKeyboard
    {
        [[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder)
                                                   to:nil
                                                 from:nil
                                             forEvent:nil];
    }
    

提交回复
热议问题