键盘在UIActionSheet中不适用于UITextField

时间:2013-02-11 11:01:07

标签: objective-c cocoa-touch uiactionsheet

动作表随textfield一起显示。当我点击文本字段时,键盘出现但不起作用..当我输入时,它们在文本字段中不可见

UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:@"Select reminder date and time"
                                                  delegate:self
                                         cancelButtonTitle:@"Cancel"
                                    destructiveButtonTitle:@"Save"
                                         otherButtonTitles:nil,nil];
menu.tag =10;
[menu showInView:self.view];
UITextField  *txtReminderTitle= [[UITextField alloc] initWithFrame:CGRectMake(20.0, 190, 280.0, 40.0)];
[txtReminderTitle setTag:99];
[txtReminderTitle setBackgroundColor:[UIColor whiteColor]];
[txtReminderTitle setFont:[UIFont boldSystemFontOfSize:17]];
[txtReminderTitle setBorderStyle:UITextBorderStyleNone];
[txtReminderTitle setTextAlignment:UITextAlignmentCenter];
txtReminderTitle.borderStyle = UITextBorderStyleRoundedRect;
txtReminderTitle.keyboardType = UIKeyboardTypeDefault;
txtReminderTitle.returnKeyType = UIReturnKeyDone;
txtReminderTitle.delegate =self;
[menu addSubview:txtReminderTitle];

请把我拉出这个问题.. 提前谢谢。

1 个答案:

答案 0 :(得分:0)

我发现,当您将UITextField添加到UIActionSheet时,UITextField保留在UIActionSheet下,因此您需要在UITextField上方显示UIActionSheet }

编写以下代码以添加UITextField

UIWindow *appWindow = [UIApplication sharedApplication].keyWindow;
[appWindow insertSubview:txtReminderTitle aboveSubview:menu];
相关问题