国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

防止鍵盤擋住textFiled的解決方案

2019-11-09 17:46:23
字體:
來源:轉載
供稿:網友
鍵盤出現實現textfield的代理方法- (void)textFieldDidBeginEditing:(UITextField *)textField{   CGRect frame = textField.frame;   CGPoint rootFrame = [[textField superview] convertPoint:frame.origin toView:self.view];//把控件的坐標轉為相對于屏幕的坐標   int offset = rootFrame.y + 56 - (self.view.frame.size.height - 216.0);//鍵盤高度216   NSTimeInterval animationDuration = 0.30f;   [UIView beginAnimations:@"ResizeForKeyBoard" context:nil];   [UIView setAnimationDuration:animationDuration];   float width = self.view.frame.size.width;   float height = self.view.frame.size.height;   if(offset > 0){       CGRect rect = CGRectMake(0.0f, -offset,width,height);       self.view.frame = rect;   }   [UIView commitAnimations];}鍵盤收起- (IBAction)hideKeyboard:(id)sender {   NSTimeInterval animationDuration = 0.30f;   [UIView beginAnimations:@"ResizeForKeyboard" context:nil];   [UIView setAnimationDuration:animationDuration];   CGRect rect = CGRectMake(0.0f, 0.0f, self.view.frame.size.width, self.view.frame.size.height);   self.view.frame = rect;   [UIView commitAnimations];   //在這把textField的第一焦點去掉}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 富裕县| 交城县| 电白县| 五台县| 栾川县| 长春市| 遵义市| 始兴县| 崇左市| 怀远县| 长寿区| 伊春市| 阜宁县| 张家口市| 邵武市| 美姑县| 唐河县| 浦北县| 玉山县| 南京市| 河北省| 铅山县| 工布江达县| 凤翔县| 肃宁县| 德化县| 康乐县| 伊金霍洛旗| 天柱县| 五华县| 灌阳县| 兰溪市| 安乡县| 长乐市| 康保县| 河池市| 台江县| 前郭尔| 永清县| 宣武区| 建昌县|