0
我想添加一个功能,当我点击一个特定的文本框,然后有一个下拉/表格视图在GUI前,我可以选择一个值,然后选定的值是插入到文本字段中?UITextfield mimic下拉菜单(UITableView?)
如何以最简单的方式实现此目的?
我想添加一个功能,当我点击一个特定的文本框,然后有一个下拉/表格视图在GUI前,我可以选择一个值,然后选定的值是插入到文本字段中?UITextfield mimic下拉菜单(UITableView?)
如何以最简单的方式实现此目的?
取决于,如果这是在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“s,你需要那些为Picker视图腾出空间。结果如下:
我收到很多错误和wanrings(未声明的标识符'self'?) –
您可以复制粘贴相关代码吗? – 0xSina
使用未声明的标识符'entry',[actionSheet setDelegate:self]; =>期望的标识符或'(',使用未声明的标识符'row',[pv setShowsSelectionIndicator:YES]; =>期望的标识符或'(' –