[英]UITableView Rows selection with UIPicker Option
我有一個包含5行的tableview
,當我選擇一行時,它會在下一頁打開一個UIPickerView
來選擇選項,同樣的事情發生在5行上。 )無論我選擇了哪個
我在同一頁面上有一個按鈕來對選定的行值(UIPicker值)執行。如何在Button.to中給出選項以選擇從UIPicker
獲取的行數
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if(indexPath.row==0){
Picker1 *logInController = [[Picker1 alloc] init];
[[self navigationController] pushViewController:logInController animated:YES];
}
if(indexPath.row==1){
Picker2 *logInController = [[Picker2 alloc] init];
[[self navigationController] pushViewController:logInController animated:YES];
}
}
像上面一樣,我已經打開了UIPIcker
並選擇了選項。
在PICKER1.m
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
// update label text to show selected option
NSString* string=[NSString stringWithFormat:@"you are selected %@",[list objectAtIndex:row]];
label.text=string;
}
- (void)viewDidLoad
{
[super viewDidLoad];
list =[[NSMutableArray alloc]init];
[list addObject:@"GPS"];
[list addObject:@"NONE"];
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.