Il devrait être possible d'ajuster la position du cadre de la vue sur laquelle UITextField est activé. consultez ce code:
http://iphoneincubator.com/blog/tag/uitextfield
- (void)textFieldDidBeginEditing:(UITextField *)textField {
[self scrollViewToCenterOfScreen:textField];
}
- (void)scrollViewToCenterOfScreen:(UIView *)theView {
CGFloat viewCenterY = theView.center.y;
CGRect applicationFrame = [[UIScreen mainScreen] applicationFrame];
CGFloat availableHeight = applicationFrame.size.height - keyboardBounds.size.height; // Remove area covered by keyboard
CGFloat y = viewCenterY - availableHeight/2.0;
if (y < 0) {
y = 0;
}
scrollView.contentSize = CGSizeMake(applicationFrame.size.width, applicationFrame.size.height + keyboardBounds.size.height);
[scrollView setContentOffset:CGPointMake(0, y) animated:YES];
}
je veux le faire sans défilante monsieur .. vous avez utilisé défilante –
remplacer simplement la variable ScrollView avec la vue actuelle. J'ai utilisé ce code avec des scrollviews, des vues et des vues de table. Le code détermine simplement où se trouve votre champ de texte et calcule la distance animée. Utilisez cette variable pour ajuster le cadre de votre vue. – Dutchie432
Comment obtenez-vous keyboardBounds? –