首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用操作表时隐藏keyBoard的问题

使用操作表时隐藏keyBoard的问题
EN

Stack Overflow用户
提问于 2012-12-13 21:54:48
回答 2查看 885关注 0票数 0

我在textFieldDidBeginEditing上展示了动作单,下面是我的代码:

代码语言:javascript
复制
- (void)textFieldDidBeginEditing:(UITextField *)textField {
    // dept_label is my UITextField property
    if (textField == dept_label) {
        [textField setUserInteractionEnabled:YES]; // i also used dept_label instead textfield here...
        [textField resignFirstResponder];
        UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select"
                                                                 delegate:self
                                                        cancelButtonTitle:@"OK"
                                                   destructiveButtonTitle:nil
                                                        otherButtonTitles:@"Manpower", @"Admin",@"Research" ,nil];
        [actionSheet setActionSheetStyle:UIActionSheetStyleDefault];
        [actionSheet showInView:self.view];
    }
}

问题是动作单被激活了,但是键盘没有被隐藏起来!

EN

Stack Overflow用户

回答已采纳

发布于 2012-12-14 13:39:46

代码语言:javascript
复制
finally this worked..

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
    if(textField==dept_label){        
        [textField setUserInteractionEnabled:YES]; 
        [textField resignFirstResponder];

            UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select" delegate:self cancelButtonTitle:@"OK" destructiveButtonTitle:nil otherButtonTitles:@"Manpower", @"Admin",@"Research" ,nil];
    actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
    [actionSheet showInView:self.view];        

    }       
    return YES;      
}
票数 0
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13861326

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档