Reputation: 3234
Is there something wrong with this code because when i press the button to pop up the UIPickerview
. Nothing happens. Why is that
-(void)pickerview:(id)sender
{
items =[[NSArray alloc]initWithObjects:@"Hindi",@"English",nil];
pickerView=[[UIPickerView alloc] initWithFrame:CGRectMake(10,100,150,150)];
pickerView.transform = CGAffineTransformMakeScale(0.75f, 0.75f);
pickerView.delegate = self;
pickerView.dataSource = self;
pickerView.showsSelectionIndicator = YES;
pickerView.backgroundColor = [UIColor clearColor];
[pickerView selectRow:1 inComponent:0 animated:YES];
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView;
{
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component;
{
return [items count];
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
return[items objectAtIndex:row];
}
Can someone please tell me what is wrong with this code.
Upvotes: 4
Views: 10466
Reputation: 21805
yeah.. big problem ..
[self.view addSubview:pickerview];
is missing
also are you sure your button press is calling this method..it returns (void
) .. if connected to xib component it should show IBAction
Upvotes: 6