IOS開發學習筆記-(2)鍵盤控制,鍵盤類型設定,alert 對話方塊
一、關閉鍵盤,放棄第一響應者,處理思路有兩種
① 使用文字框的 Did End on Exit 綁定事件
② UIControl on Touch 事件 都去操作 sender 的 resignFirstResponder
#import @interface ViewController : UIViewController@property (weak, nonatomic) IBOutlet UITextField *txtUserName;@property (weak, nonatomic) IBOutlet UITextField *txtUserPwd;- (IBAction)onclick_UserLogin:(id)sender;//關閉鍵盤- (IBAction)hideKeyBorad:(id)sender;@end
.m 檔案中
//放棄第一響應者- (IBAction)hideKeyBorad:(id)sender{ [txtUserName resignFirstResponder]; [txtUserPwd resignFirstResponder];}
按照如下進行事件關聯
二、鍵盤類型,Return Key,通過設定文字框的屬性來實現,切換,email輸入框,number數字輸入框,weburl輸入框等,如:
三、alert對話方塊顯示 , 綁定 【測試登入】 按鈕的事件 ,設定彈出alert
<喎?http://www.bkjia.com/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHByZSBjbGFzcz0="brush:java;"> UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"溫馨提示" message:@"你好,資料已經更新完畢" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"確定",@"請選擇",@"請投票",nil]; [alertView show];
運行效果如下:
代碼地址:http://download.csdn.net/detail/jiangtao_st/7684869