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]; =>期望的標識符或'(' –