简体   繁体   中英

selected Item in single picker is null

I have single picker when the user select type it will update label but when I select item it equal null to label

    //update label type
    NSInteger row  = [singlePicker selectedRowInComponent:0];
   NSString *selected = [pickerData objectAtIndex:row];
   NSString *strTypeSelected  = [[NSString alloc] initWithFormat:@"%@",selected];


    typelabel.text =strTypeSelected;

首先,请确保将插座和数据源提供给UIPickerView singlePicker对象,然后尝试使用此代码。

typelabel.text = [pickerData  objectAtIndex:[singlePicker selectedRowInComponent:0]];

Try This,

txtField1.text = [NSString stringWithFormat:@"%@",[arrData objectAtIndex:[picker selectedRowInComponent:0]]];

Check picker.delegate = self; in .m file -> viewDidLoad method.

Check in .h File

...Controller<UIPickerViewDataSource, UIPickerViewDelegate> {...

It may be help you.
Thanks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM