1
我創建了uitextfield作爲uiimageview的子視圖& textfield和uiimageview都是scrollview的子視圖。在編輯文本框時隱藏鍵盤的方法是什麼。 在這裏我的代碼,它不工作。如何解除ios中的自定義文本字段的鍵盤
{
img1=[[UIImageView alloc]initWithFrame:CGRectMake(0, 1, 320, 60)];
img1.userInteractionEnabled=YES;
NSString *imgfilepath=[[NSBundle mainBundle]pathForResource:@"123" ofType:@"png"];
UIImage *imo=[[UIImage alloc]initWithContentsOfFile:imgfilepath];
[img1 setImage:imo];
UILabel *label1;
label1=[[UILabel alloc]init];
label1.frame=CGRectMake(60, 0, 250, 30);
[email protected]"ENTER ANNUAL INCOME";
label1.textColor=[UIColor blackColor];
label1.font=[UIFont italicSystemFontOfSize:16.0f];
label1.backgroundColor=[UIColor clearColor];
[img1 addSubview:label1];
principal = [[UITextField alloc] initWithFrame:CGRectMake(85,30, 156, 40)];
principal.backgroundColor = [UIColor clearColor];
principal.clearButtonMode = UITextFieldViewModeWhileEditing;
principal.font = [UIFont systemFontOfSize:15.0f];
[email protected]"ENTER";
[principal setKeyboardType:UIKeyboardTypeNumberPad];
//principal.textAlignment=UITextAlignmentCenter;
[img1 addSubview:principal];
[img1 respondsToSelector:[principal resignFirstResponder]];
[scrollview addSubview:img1];
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[principal resignFirstResponder];
}
這些方法在哪些類中? –