0

国リストと対応するフラグを備えたカスタムピッカーがありますが、すべてが正常に機能しますが、国を選択したときに国名と背景画像としてのフラグを表示したいのですが、メソッドでテキストをテキストに設定できない理由がわかりません。私には意味がありません。これは私のコードです:私の「国」NSSTringがインターフェースで適切に宣言され、.mで合成され、namefieldTextIBOutletが接続されていることに注意してください。コード:

- (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 
}
4

1 に答える 1

1

問題はあなたにあります:

国=[customPickerArrayobjectAtIndex:[pickerView selectedRowInComponent:0]];

代わりに、次のように言う必要があります。

国=[customPickerArrayobjectAtIndex:row];

幸運を!

于 2012-11-27T00:37:02.270 に答える