鍵盤出現(xiàn)實(shí)現(xiàn)textfield的代理方法- (void)textFieldDidBeginEditing:(UITextField *)textField{   CGRect frame = textField.frame;   CGPoint rootFrame = [[textField superview] convertPoint:frame.origin toView:self.view];//把控件的坐標(biāo)轉(zhuǎn)為相對(duì)于屏幕的坐標(biāo)   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的第一焦點(diǎn)去掉}
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注