Popup UIPickerview at the click of a button

Something is wrong with this code, because when I click the button, you open UIPickerview . Nothing has happened. Why is this

  -(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.

+4
source share
1 answer

yes .. big problem ..

 [self.view addSubview:pickerview]; 

absent

also you are sure that your button is pressed, calls this method .. it returns ( void ) .. if connected to the xib component, it should show IBAction

+6
source

Source: https://habr.com/ru/post/1399854/


All Articles