我想在视图上显示文本字段。该视图的代码是
if (indexPath.row==0) {
UIView *viewshow=[[[UIView alloc]init]autorelease];
viewshow.frame = CGRectMake(5, 60, 310, 230);
viewshow.backgroundColor=[UIColor whiteColor];
[cell addSubview:viewshow];
}
并通过此代码获取自定义文本字段
if (indexPath.row==0) {
UIView *viewshow=[[[UIView alloc]init]autorelease];
viewshow.frame = CGRectMake(5, 60, 310, 230);
viewshow.backgroundColor=[UIColor whiteColor];
[cell addSubview:viewshow];
UITextField* textField = [[UITextField alloc] initWithFrame:CGRectMake(5, 10, 30, 200)];
textField.borderStyle = UITextBorderStyleRoundedRect;
textField.placeholder = @"Enter the Text";
textField.font = [UIFont fontWithName:@"Helvetica" size:12.0];
textField.delegate = self;
//cell.accessoryView = textField;
[viewshow addSubview:textField];
}
现在文本字段在垂直方向上而不是在视图中的水平方向上。现在我不明白我需要做什么来解决这个问题。 请帮忙.....
答案 0 :(得分:0)
更改uitextfield
的框架宽度和高度,即
UITextField* textField = [[UITextField alloc] initWithFrame:CGRectMake(5, 10, 200, 30)];