1

私は Iphone を初めて使用し、UIPickerView を使用する必要があるアプリケーションに取り組んでいます。UIPickerView を静的に設定することはできますが、今度は WEBSERVICES からデータを取得して Picker View に設定する必要があります。

ステップバイステップのガイダンスを教えてください。

4

2 に答える 2

1

そのためには、UIPickerViewデリゲートメソッドと1つを使用できますMutableArray。Webサービスの応答を保存し、それをデリゲートメソッドで
使用するために使用します。MutableArrayUIPickerView

// number of component to display in the pickerview
    - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView 
    {
        return 1;
    }

// numbers of row is the total numbers of object store in your array

    - (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component 
    {

        return [YourArray count];
    }

//display your title

    - (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component 
    {
        NSString *obj = [YourArray objectAtIndex:row];
        return obj; 

    }

// on click whatever you want to do.
    - (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component 
    {

       // onClick i am displaying the picker value in my textview you can do as per your requirement.
                mytextview.text=[YourArray  objectAtIndex:row];

    }
于 2013-02-13T04:36:47.517 に答える