2016-06-22 5 views
0

UITextFieldが動的に作成されるビューコントローラを作成しています。私はUITextFieldの検証を行う際にここでテキストフィールドで検証を実行すると、テキストフィールドとテキストエリアが応答しなくなる

self.ansText = [[UITextField alloc] init]; 
       self.ansText.tag = 1; 
       self.ansText.delegate = self; 

       [_ansText createAnsTextwithParentFrame:QuestionView.frame withUpperFrame:questSeq2Frame]; 

       [QuestionView addSubview:_ansText]; 

は、さらには他のビューコントローラのテキストフィールドは、スタック内の同様の質問の数を経ていUITextField ShouldBeginEditing method.Iに達しているunresponsive.HereなっI overflow.Andデリゲートを自己に設定しないような解決策を見た。しかし誰もこのことで私を助けてくれませんか...これについて詳しく教えてください。事前にどうもありがとうございました。

+0

を実装する必要があります。 shouldBeginEditingメソッドでYESまたはNOを返しますか? – Gati

+0

@Gati:それはYESのみを返す – iOSManiac

答えて

0

@iOSManiac、デリゲートはUITextFieldのことができ、それはここで、より詳細な回答だちょうど self.ansText.delegate = ansText;

+0

申し訳ありません、これは私のために働いていません – iOSManiac

0

、あなたとテキストはUITextFieldですから継承されている必要があり、それはあなたが書いた何UITextFieldDelegate

@interface ViewController() 

@end 


@interface AnsText : UITextField <UITextFieldDelegate> 

@end 

@implementation AnsText 

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField { 
    NSLog(@"textFieldShouldBeginEditing"); 
    return YES; 
} 

@end 



@implementation ViewController 

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    AnsText *ansText = [[AnsText alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)]; 
    ansText.tag = 1; 
    ansText.delegate = ansText; 
    [self.view addSubview:ansText]; 
} 

- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

@end 
関連する問題