Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/116.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios iphone:键盘没有隐藏_Ios_Iphone_Uitextfield_Uialertview_Resignfirstresponder - Fatal编程技术网

Ios iphone:键盘没有隐藏

Ios iphone:键盘没有隐藏,ios,iphone,uitextfield,uialertview,resignfirstresponder,Ios,Iphone,Uitextfield,Uialertview,Resignfirstresponder,我有一种情况,我有一个alertview,其中有一个文本字段是以编程方式绘制的 UIAlertView *alertView=[[UIAlertView alloc] initWithTitle:@"Welcome" message:@"Enter you name" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; nameField = [[UITextField alloc] initWithFrame:CG

我有一种情况,我有一个alertview,其中有一个文本字段是以编程方式绘制的

UIAlertView *alertView=[[UIAlertView alloc] initWithTitle:@"Welcome" message:@"Enter you name" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];

    nameField = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 45.0, 245.0, 25.0)];

    [nameField setBorderStyle:UITextBorderStyleRoundedRect];
    [nameField setPlaceholder:@"Enter Owners name"];
    [nameField setTextAlignment:UITextAlignmentCenter];
    [nameField setDelegate:self];
    [nameField setBackgroundColor:[UIColor clearColor]];

    [alertView addSubview:nameField];
    CGAffineTransform moveUp = CGAffineTransformMakeTranslation(0.0, -80.00);
    [alertView setTransform: moveUp];

    [alertView show];
    [alertView release];
为了隐藏键盘,我使用了这个

- (BOOL)textFieldShouldReturn:(UITextField *)textField{

[textField resignFirstResponder];
return YES;
}


但键盘并没有隐藏。请帮我一下。

你可以用这个隐藏你的键盘。单击模拟器/仿真器/iOS设备的背景时,这将起作用

  -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

            [yourtextfield resignFirstResponder];

            // you can have multiple textfields here


        }

您可以使用此选项隐藏键盘。单击模拟器/仿真器/iOS设备的背景时,这将起作用

  -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

            [yourtextfield resignFirstResponder];

            // you can have multiple textfields here


        }

嘿,这很酷,我用了一个不可见的按钮来隐藏键盘。只是一个问题,它在任何视图控制器上工作吗?或者我们需要做一些额外的事情?这应该可以在任何viewcontroller中完成,而无需进行任何修改。也可以在答案旁边将我的答案标记为已接受。:)嘿,这很酷,我用了一个不可见的按钮来隐藏键盘。只是一个问题,它在任何视图控制器上工作吗?或者我们需要做一些额外的事情?这应该可以在任何viewcontroller中完成,而无需进行任何修改。也可以在答案旁边将我的答案标记为已接受。:)