2
我在UIActionsheet中创建textField,但我不能输入文本,任何人都可以有想法吗?如何在UIActionSheet中的UITextField中启用文本输入?
我的编码是遵循
-(void)commentsMethod: (id) sender {
//setup UITextField for the UIActionSheet
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 28, 320, 150)];
//textField.delegate=self;
textField.autocorrectionType = UITextAutocorrectionTypeNo;
[textField setBackgroundColor:[UIColor clearColor]];
[textField setBorderStyle:UITextBorderStyleRoundedRect];
[textField becomeFirstResponder];
//CGRectMake(<#CGFloat x#>, <#CGFloat y#>, <#CGFloat width#>, <#CGFloat height#>)
UIButton *btn = [[UIButton alloc] init];
[btn setFrame:CGRectMake(0, 0, 100, 100)];
[btn setTitle:@"dismiss" forState:UIControlStateNormal];
[btn setBackgroundColor:[UIColor clearColor]];
[btn addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
UIActionSheet *myActionSheet;
myActionSheet = [[UIActionSheet alloc] initWithTitle:@"Comments" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil, nil];
myActionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[myActionSheet showInView:self.view];
myActionSheet.userInteractionEnabled=YES;
[myActionSheet setFrame:CGRectMake(0, 20, 320,600)];
[myActionSheet insertSubview:textField atIndex:0];
[myActionSheet insertSubview:btn atIndex:1];
//[self.myActionSheet dismissWithClickedButtonIndex:0 animated:NO];
//memory management
[textField release];
[myActionSheet release];
}
为什么你无法输入文字? – Vladimir 2011-02-23 10:12:34
无论我在键盘上点击,例如A B C D ,,,,在textField中什么也看不到, – 2011-02-23 10:19:14