为了我的生命,我不知道我该如何设定
UITextField
垂直(横向模式)而不是水平(纵向模式)显示文本。键盘显示正确,但当按键时,文本输入方向错误。
这是
window
这是视图控制器的代码
#import "HighScoreViewController.h"
@implementation HighScoreViewController
- (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;
txt.keyboardType = UIKeyboardTypeDefault;
txt.returnKeyType = UIReturnKeyDone;
txt.clearButtonMode = UITextFieldViewModeWhileEditing;
txt.text = @"test";
[self.view addSubview:txt];
[txt release];
}
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIDeviceOrientationLandscapeRight);
}
@end