У меня есть родительский контроль над объектом. У меня есть пользовательский вид, когда этот пользовательский вид инициализирован. Я настраиваю другой пользовательский вид, и это представление имеет UITextFields, но когда я нажимаю на UITextfield, клавиатура никогда показывает.UITextField - Клавиатура, не показывающая
ViewController:
//
// ViewController.m
// InstantForum
//
// Created by trikam patel on 27/08/2014.
// Copyright (c) 2014 trikam patel. All rights reserved.
//
#import "ViewController.h"
@interface ViewController()
@end
@implementation ViewController
@synthesize loginSignupControlView;
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.userInteractionEnabled = YES;
CGRect screenRect = [[UIScreen mainScreen] applicationFrame];
self.loginSignupControlView = [[LoginSignupControlView alloc] initWithFrame:CGRectMake(0, 0, screenRect.size.width, 68)];
[self.view addSubview:self.loginSignupControlView];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
пользовательский вид, который содержит другой пользовательский вид, который держит UITextFields
//
// LoginSignupControlView.m
// InstantForum
//
// Created by trikam patel on 28/08/2014.
// Copyright (c) 2014 trikam patel. All rights reserved.
//
#import "LoginSignupControlView.h"
#import "UIHelper.h"
#import "TextField.h"
@implementation LoginSignupControlView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self createView];
}
return self;
}
-(void)createView{
self.isLogin = true;
self.userInteractionEnabled = YES;
self.backgroundColor = [UIColor colorWithRed:56.f/255 green:56.f/255 blue:57.f/255 alpha:1.0f];
self.logoLabel = [UIHelper getUILabel:CGRectMake(10,35, 200, 14) :@"INSTANT FORUM" :[UIColor colorWithRed:222.0f/255 green:221.0f/255 blue:221.0f/255 alpha:1.0f] :[UIFont fontWithName:@"Helvetica" size:14]];
[self addSubview:self.logoLabel];
self.loginLabel = [UIHelper getUILabel:CGRectMake(190,35, 50, 14) :@"LOGIN" :[UIColor colorWithRed:106.0f/255 green:196.0f/255 blue:229.0f/255 alpha:1.0f] :[UIFont fontWithName:@"Helvetica" size:14]];
[self addSubview:self.loginLabel];
self.signupLabel = [UIHelper getUILabel:CGRectMake(250,35, 60, 14) :@"SIGNUP" :[UIColor colorWithRed:106.0f/255 green:196.0f/255 blue:229.0f/255 alpha:1.0f] :[UIFont fontWithName:@"Helvetica" size:14]];
[self addSubview:self.signupLabel];
[self setupView];
}
-(void)setupView{
if(self.isLogin){
CGRect screenRect = [[UIScreen mainScreen] applicationFrame];
self.loginView = [[LoginView alloc] initWithFrame:CGRectMake(0, 68, screenRect.size.width, 286)];
[self addSubview:self.loginView];
self.imageViewFN = [UIHelper getUIImageView:CGRectMake(10, 10, 300, 35) :@"textbox1.png"];
[self.loginView addSubview:self.imageViewFN];
TextField *fnText = [[TextField alloc] initWithFrame:CGRectMake(20, 10, 280, 35)];
//fnText.backgroundColor = [UIColor clearColor];
fnText.text = @"Enter First Name";
fnText.userInteractionEnabled = YES;
fnText.enabled = YES;
fnText.font = [UIFont fontWithName:@"Helvetica" size:14];
fnText.textColor = [UIColor colorWithRed:105.0f/255 green:121.0f/255 blue:221.0f/255 alpha:1.0f];
[self.loginView addSubview:fnText];
}
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/
@end
Выборочная вид, LoginView
//
// LoginView.m
// InstantForum
//
// Created by trikam patel on 28/08/2014.
// Copyright (c) 2014 trikam patel. All rights reserved.
//
#import "LoginView.h"
@implementation LoginView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor colorWithRed:61.0f/255 green:81.0f/255 blue:168.0f/255 alpha:1.0f];
self.userInteractionEnabled = YES;
}
return self;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/
@end
Im тестируя это на моем устройстве iPhone – redoc01
@ redoc01 Вы представляете, как контроллер представлен модально? – Fer
Контроллер вида является контроллером родительского представления – redoc01