在UIViewController中收起鍵盤忽你,除了調(diào)用相應控件的resignFirstResponder方法外,還有另外三種方法:
- 重載UIViewController中的touchesBegin方法冠绢,然后在里面執(zhí)行[self.view endEditing:YES];雁刷,這樣單機UIViewController的任意地方荠察,就可以收起鍵盤。
- 直接執(zhí)行[[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil];镣煮,用于在獲得當前UIViewController比較困難的情況.
- 直接執(zhí)行[[[UIApplication sharedApplication] keyWindow] endEditing:YES];