2012-04-08 66 views
0

我有一個自定義選擇器與國家名單和相應的標誌一切工作正常,但我想當國家被選中國家名稱和國旗作爲背景圖片來顯示,我不明白爲什麼我的方法不能將文本設置爲文本,對我來說沒有任何意義。 這是我的代碼:請注意我的「國家」NSSTring已在接口中正確聲明並在.m 和namefieldText IBOutlet已連接中合成。 代碼:UIPicker不會設置文本字段

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component 
{ 
    // report the selection to the UI label 

    country = [customPickerArray objectAtIndex:[pickerView selectedRowInComponent:0]]; 

     nameFiled.text =country;  // Nothing happens here 

    NSLog(@"%@",country);   //NSLog show correctly selected country in a console 
} 

回答

1

的問題是與你:

國家= [customPickerArray objectAtIndex:[pickerView selectedRowInComponent:0];

相反,你應該說:

國家= [customPickerArray objectAtIndex:行]。

祝你好運!