I am using a code to a text field ,it works fine (with cocos2d also), but i cant understand why the keyboard is open when i start the app? i want it to be like that :
- when you open the app, you see a rect-which is the textfield(i dont know how to put that rect?? ) and ONLY when you touch it , it opens the keyboard and you can type .
any help to do this would be great .
my code: ( setText is called in init )
-(void)setText
{
myText = [[UITextField alloc] initWithFrame:CGRectMake(100, 120, 200, 90)];
myText.transform = CGAffineTransformMakeRotation( M_PI / 2.0 );
[myText setDelegate:self];
[myText setText:@"yes"];
[myText setTextColor: [UIColor colorWithRed:0 green:0 blue:0 alpha:1.0]];
[[[[CCDirector sharedDirector] openGLView] window] addSubview:myText];
[myText becomeFirstResponder];
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
[myText resignFirstResponder];
return YES;
}
-(void)textFieldDidEndEditing: (UITextField *)textField {
if(textField == myText)
{
[myText endEditing:YES];
[myText removeFromSuperview];
NSString *result = myText.text;
NSLog(@"%@",result);
}
else
{
NSLog(@"textField did not match myText");
}
}
because you put this:
take it out and it should not bring the keyboard when your app is load.