添加下拉菜单iOS

时间:2016-02-09 13:03:29

标签: ios uitableview drop-down-menu uitextfield uicontrol

如何设置UITextField,以便当用户触摸它时,字段下会出现一个包含相似项目(每个名称,照片和详细信息)的小表,因此通过选择任何行,某些数据会填充该字段。 / p>

也许就像在android中的下拉菜单一样!

提前致谢!

我用这种方式解决了问题:

UIViewController *cardVC = [UIViewController new];
cardVC.view = [[UITableView alloc] initWithFrame:CGRectMake(f.origin.x, f.origin.y + f.size.height + 5, f.size.width, 90 * COUNT)];
//add kardan table be view
[cardVC.tableView reloadData];
[self.view addSubview:cardVC.view];

但它不会在表格中加载任何数据!任何人都可以帮忙吗?

4 个答案:

答案 0 :(得分:1)

我通过在storyboard中的textfield下创建一个隐藏的tableview来解决这个问题!

答案 1 :(得分:0)

使用文本字段委托方法" shouldChangeCharactersInRange"当它调用时添加你想要使用的搜索逻辑,如果你有任何结果在文本字段下方添加表格,当你没有得到任何结果时删除该表格。

答案 2 :(得分:0)

你需要自己构建它,或者也许离子github有你需要的东西 您可以创建由Private Sub Worksheet_Change(ByVal Target As Range) Dim KeyCells As Range ' The variable KeyCells contains the cells that will ' cause an alert when they are changed. Set KeyCells = Range("J3:J1000") If Not Application.Intersect(KeyCells, Range(Target.Address)) _ Is Nothing Then ' Display a message when one of the designated cells has been ' changed. ' Place your code here. Dim answer As String Dim SubmitLink As String SubmitLink = Target.Offset(, -8).Value answer = MsgBox("Do you wish to save this change. An Email will be sent to the User", vbYesNo, "Save the change") If answer = vbNo Then Cancel = True If answer = vbYes Then 'open outlook type stuff Set OutlookApp = CreateObject("Outlook.Application") Set OlObjects = OutlookApp.GetNamespace("MAPI") Set newmsg = OutlookApp.CreateItem(olMailItem) 'add recipients 'newmsg.Recipients.Add ("Name Here") newmsg.Recipients.Add Worksheets("Coordinator").Range("Q4").Value 'add subject newmsg.Subject = Worksheets("Coordinator").Range("O3").Value 'add body newmsg.Body = "Dear User, New Submittal ( " & SubmitLink & " ) has been Added in submittal Log. Please Investigate the Change" & vbLf & vbLf & vbLf & "Sincerely," newmsg.Display 'display newmsg.Send 'send message 'give conformation of sent message MsgBox "Modification confirmed", , "Confirmation" End If ' MsgBox "Cell " & Target.Address & " has changed." End If End Sub 和隐藏UITextField组成的自定义视图 当用户使用文本字段委托协议点击文本字段时,您可以意识到用户正在键入,根据键入的内容,您可以在表格视图上显示结果。

答案 3 :(得分:0)

如果你想实现自动完成,可以试试这个:https://github.com/EddyBorja/MLPAutoCompleteTextField