Я добавляю UITextField
к моему приложению, и оно должно быть 300x30, но в итоге оно составляет 600x60. Вот то, что я до сих пор ... В моем приложении делегат:Почему этот UITextField вдвое больше, чем ожидалось?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
OpenGLViewController* controller = [[OpenGLViewController alloc] init];
[self.window setRootViewController:controller];
[self.window addSubview:controller.view];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[self.window makeKeyAndVisible];
return YES;
}
и в OpenGLViewController
:
- (void)loadView {
self.view = [[OpenGLView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 300, 30)];
textField.borderStyle = UITextBorderStyleRoundedRect;
textField.font = [UIFont systemFontOfSize:15];
textField.placeholder = @"Search...";
textField.autocorrectionType = UITextAutocorrectionTypeNo;
textField.keyboardType = UIKeyboardTypeDefault;
textField.returnKeyType = UIReturnKeyDone;
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
textField.returnKeyType = UIReturnKeySearch;
textField.delegate = self;
[self.view addSubview:textField];
}
внутри моей OpenGlView
«с инициализации (я не думаю, что это влияет на размер):
- (id)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
[self setupLayer];
[self setupContext];
[self setupRenderBuffer];
[self setupFrameBuffer];
[self compileShaders];
glViewport(0, 0, frame.size.width, frame.size.height);
}
return self;
}
Почему это UITextField
вдвое больше, чем это должно быть?
Из любопытства, если вы меняете его на 150X15, он подходит к размеру, который вы хотите? –