国产探花免费观看_亚洲丰满少妇自慰呻吟_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的第一焦點去掉}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 塘沽区| 巩义市| 阆中市| 简阳市| 新化县| 武冈市| 长泰县| 黄冈市| 望都县| 广水市| 汝城县| 镇巴县| 涿州市| 阳曲县| 靖远县| 沈阳市| 岱山县| 阳谷县| 罗山县| 介休市| 亚东县| 新乡县| 沧州市| 湘乡市| 平和县| 青铜峡市| 油尖旺区| 蓝山县| 陵川县| 八宿县| 观塘区| 尤溪县| 江孜县| 上杭县| 九江市| 新和县| 崇明县| 瑞丽市| 姜堰市| 沙田区| 深泽县|