在UIViewController中收起鍵盤,除了調(diào)用相應(yīng)控件的resignFirstResponder方法外,還有另外3種方法:
1.重載UIViewController中的touchesBegin方法,然后在里面執(zhí)行[self.view endEditing:YES];,這樣單擊UIViewController中任意地方,就可以收起鍵盤;
2.直接執(zhí)行[[UIapplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil];,用于在獲得當(dāng)前UIViewController比較困難的時(shí)候用;
3.直接執(zhí)行[[[UIApplication sharedApplication] keyWindow] endEditing:YES]。
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注