在textfield的输入框 输入文本 怎么弹出界面呢 用的哪个方法

在textfield的输入框 输入文本 怎么弹出界面呢 用的哪个方法

http://img1.sycdn.imooc.com//climg/5c209b9c0001b28007501525.jpg

在输入框输入文字  怎么弹出界面  是用的哪个方法呢

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

3回答
Tender10 2018-12-25 17:53:13
// 先设置代理
self.textfield.delegate=self;
// 再用代理方法
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];// 1
[self.textField becomeFirstResponder];// 2
}

1、是调用父类代理方法 

2、是将textfield设成第一响应者

Tender10 2018-12-25 10:27:24
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
    SearchVC* vc = [SearchMapPointVC new];
    [vc setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
    vc.delegate = self;
    [self.navigationController presentViewController:vc animated:YES completion:nil];
    
    return NO;
}

如上代码所示,调用UITextField的代理方法textFieldShouldBeginEditing:然后在方法里实现弹窗。点击搜索按钮取消,那就在搜索按钮的响应方法里去取消弹窗。

  • 提问者 慕粉1472629313 #1
    -(BOOL)textFieldShouldBeginEditing:(UITextField *)textField{ [self showListV]; return NO; } -(void)showListV{ _tableview = [[UITableView alloc]initWithFrame:CGRectMake(50, 0, 273, 200) style:UITableViewStylePlain]; _tableview.delegate = self; _tableview.dataSource = self; _tableview.tableFooterView = [[UIView alloc] init]; [self.view addSubview:_tableview]; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return 5;//dataArray[0] dataArray[1]dataArray[2]dataArray[3] } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 36; } 怎么在弹出tableview的同时 键盘也弹出呢
    2018-12-25 14:33:40
  • Tender10 回复 提问者 慕粉1472629313 #2
    可以调用键盘的第一响应者,这个在后面阶段的课程内容中讲解过哦,你学习过,可以再回过头看一下哦。
    2018-12-25 15:58:06
  • 提问者 慕粉1472629313 #3
    可以说详细一点吗 哪节课程
    2018-12-25 17:37:24
Tender10 2018-12-24 17:01:13

你可以具体描述一下你的问题嘛,你说的输入文字以后就立马弹出界面是弹出的什么界面?是搜索框下面出现的历史搜索记录?

  • 提问者 慕粉1472629313 #1
    对的 是弹出下面的历史搜索记录 然后在输入框输入文本 点击搜索按钮 历史搜索按钮收起
    2018-12-25 09:21:42
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师