Taranfx
Taranfx

Reputation: 10437

How do I create PickerView using code alone (no xib)

I'm not able to find examples for this, Can someone help - I need to create PickerView triggered from clicking a UIButton, filling data from Array or Dictionary without using .xib designer.

Upvotes: 1

Views: 289

Answers (1)

Robin
Robin

Reputation: 10011

in the IBAction method of the UIButton you can do

- (IBAction)buttonPressed
{
    UIDatePicker *myPicker = [[UIDatePicker alloc] initWithFrame:pickerFrame];
    [self.view addSubview:myPicker];
    [myPicker release];
}

you would have to implement the delegate and datasource methods to show the picker and its contents.

Upvotes: 1

Related Questions