简体   繁体   中英

UITextField Resigning Sporadically

This is a really odd issue because I can't give much explanation here. I have UITextField within a UITableView cell. Pretty straightforward...

When I select my UITextField it occasionally just resigns, not allowing the user to interact with the keyboard at all. This happens completely randomly and I don't have the slightest clue why it's happening. Has this happened to anyone else?

单元格滚动到屏幕之外会发生这种情况吗?

If I correct understand, you need push up (resize) your view.

1) Make sure that your textfield's delegate set to viewconntroller.

2) implement methods

-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
   [self resizeView:YES toPoint: -70]; // example
   return YES;
}


-(void)textFieldDidEndEditing:(UITextField *)textField
{
   [self resizeView:NO toPoint: 0];
}

when resizeView is:

-(void) resizeView:(BOOL)top toPoint:(int)point
{
   if (top)
       [UIView animateWithDuration:0.3 animations:^{
    self.view.transform = CGAffineTransformMakeTranslation(0, point);
}];
   else 
   {
     [UIView animateWithDuration:0.3 animations:^{
        self.view.transform = CGAffineTransformMakeTranslation(0, point);
    }];
   }
}

Also you may increase text field frame, may be randomnicity of resigning depend on touch handle by table cell cut not textfield. Try disable user interaction for table or separate cell if this possible to check it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM