Pour la vie de moi, je n'arrive pas à comprendre comment je dois régler le UITextField
pour afficher le texte verticalement (mode paysage) au lieu d'horizontalement (mode portrait). Le clavier s'affiche correctement, mais lorsque les touches sont enfoncées, le texte est entré dans la mauvaise orientation.UITextField en orientation paysage
Voici la capture d'écran pour la window
Et voici le code pour le contrôleur de vue
#import "HighScoreViewController.h"
@implementation HighScoreViewController
//Implement loadView if you want to create a view hierarchy programmatically
- (void)loadView {
UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
contentView.backgroundColor = [UIColor whiteColor];
contentView.autoresizesSubviews = YES;
contentView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
self.view = contentView;
[contentView release];
self.view.backgroundColor = [UIColor blackColor];
CGRect frame = CGRectMake(180.0, 7, 27.0, 120);
UITextField * txt = [[UITextField alloc] initWithFrame:frame];
txt.borderStyle = UITextBorderStyleBezel;
txt.textColor = [UIColor blackColor];
txt.font = [UIFont systemFontOfSize:17.0];
txt.placeholder = @"<enter name>";
txt.backgroundColor = [UIColor whiteColor];
txt.autocorrectionType = UITextAutocorrectionTypeNo; // no auto correction support
//txt.delegate = self;
txt.keyboardType = UIKeyboardTypeDefault; // use the default type input method (entire keyboard)
txt.returnKeyType = UIReturnKeyDone;
txt.clearButtonMode = UITextFieldViewModeWhileEditing; // has a clear 'x' button to the right
txt.text = @"test";
[self.view addSubview:txt];
[txt release];
}
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIDeviceOrientationLandscapeRight);
}
@end
Je suppose que je devrais avoir posté un commentaire, oui nous avons mis manuellement l'orientation lors du chargement d'applications via [[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationLandscapeRight]; Lorsque je commente cela, cela ne résout pas le problème et le clavier est maintenant en mode portrait. –