Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.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
UITextfield模拟下拉菜单(UITableView?)_Uitableview_Ios4_Xcode4_Uitextfield - Fatal编程技术网

UITextfield模拟下拉菜单(UITableView?)

UITextfield模拟下拉菜单(UITableView?),uitableview,ios4,xcode4,uitextfield,Uitableview,Ios4,Xcode4,Uitextfield,我想添加一个功能,当我点击一个特定的文本字段时,gui前面有一个下拉列表/表格视图,我可以选择一个值,然后将所选值插入文本字段 如何以最简单的方式实现这一点?取决于,如果这是在iPad上,您可以使用UIPopoverController并在其中显示UITableViewController 如果没有,您可以显示UIActionSheet并在其中添加UIPickerView或UITableView…在本例中,我正在创建UIActionSheet并在其中放置UIPickerView: NSS

我想添加一个功能,当我点击一个特定的文本字段时,gui前面有一个下拉列表/表格视图,我可以选择一个值,然后将所选值插入文本字段


如何以最简单的方式实现这一点?

取决于,如果这是在iPad上,您可以使用UIPopoverController并在其中显示UITableViewController

如果没有,您可以显示UIActionSheet并在其中添加UIPickerView或UITableView…在本例中,我正在创建UIActionSheet并在其中放置UIPickerView:

    NSString *title = UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation) ? @"\n\n\n\n\n\n\n\n\n" : @"\n\n\n\n\n\n\n\n\n\n\n\n" ;
            UIActionSheet *actionSheet = [[UIActionSheet alloc] 
                                          initWithTitle:[NSString stringWithFormat:@"%@%@", title, [entry objectForKey:@"Name"]]
                                          delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:@"Ok", nil];
[actionSheet setDelegate:self];
[actionSheet setTag:row];

pv = [[UIPickerView alloc] init];
[pv setShowsSelectionIndicator:YES];
[pv setDelegate:self];
[pv setTag:28];
[actionSheet addSubview:pv];
[actionSheet showInView:[[[self navigationController] tabBarController] view]];
[pv release];
请注意“\n”,您需要这些来为选择器视图腾出空间。结果如下:

我收到许多错误和请求(未声明的标识符'self'?)使用未声明的标识符'entry',[actionSheet setDelegate:self];=>预期标识符或“(”,使用未声明的标识符“行”;[pv SetShowsSelectIndicator:YES];=>预期标识符或“(”好的,这些都是简单的修复方法,请阅读一些关于编程的书籍/指南并从基础开始。我需要一个有效的示例和一个小教程,如果你在一周内开发一个应用程序,我如何实现这一点(只是pickerview缺少的部分)并且在发布前很短,那么你开始阅读苹果的大量文档(也有糟糕的文档)还是一本500页的书?我还想要一个没有actionsheet和tableview的解决方案,就像问题中写的那样!