2013-07-27 122 views
0

我有一個uipickerview,您可以選擇已設置到數組中的項目,但我正在努力解決如何將uilabel的文本設置爲選定選項。UIPickerView設置選擇

這裏是我用來創建uipicker委託和數據源代碼:

-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { 
    return [treatments count]; 
} 

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { 
    return 1; 
} 

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component 
{ 
     return[[treatments objectAtIndex:row]valueForKey:@"treatmentName"]; 
} 

-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { 

} 

我所知道的是,它在uipicker didselectrow功能做

在此先感謝

在下面的方法

回答

2

集文本標籤

-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { 
     yourLbl.text = [[treatments objectAtIndex:row]valueForKey:@"treatmentName"]; 
} 
+0

由於它的工作將接受w ^母雞我可以 – Ollie

+0

沒問題,你是最受歡迎的 – Pratik