Note that there are some explanatory texts on larger screens.

plurals
  1. POUIPickerView in UITableViewCell:issue in showing the value at particular cell
    text
    copied!<p>I am using the UIPickerView in UITableView for picking the integer value. I am not getting how to set the value to the label in particular cell. Below is my code:</p> <pre><code>-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell; cell = [self.mTicketTable dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } else{ cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } cell.backgroundView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"cell.bg.png"]]; cell.selectionStyle = UITableViewCellSelectionStyleNone; lblType = [[UILabel alloc]initWithFrame:CGRectMake(10, 15, 90, 30)]; lblPrice = [[UILabel alloc]initWithFrame:CGRectMake(140, 15, 90, 30)]; lblSeat = [[UILabel alloc]initWithFrame:CGRectMake(232, 21, 52, 26)]; lblSeat.text = strSelected; lblSeat.tag = indexPath.row+1; lblSeat.textColor = [UIColor lightGrayColor]; lblSeat.textAlignment = NSTextAlignmentCenter; lblSeat.backgroundColor = [UIColor clearColor]; UIButton *btnPicker = [UIButton buttonWithType:UIButtonTypeCustom]; [btnPicker setImage:[UIImage imageNamed:@"drop_down.png"] forState:UIControlStateNormal]; [btnPicker addTarget:self action:@selector(pickseats:) forControlEvents:UIControlEventTouchUpInside]; btnPicker.frame = CGRectMake(232, 20, 80, 30); self.mPickerView = [[UIPickerView alloc] init]; self.mPickerView.frame = CGRectMake(228, 100, 90, 60); self.mPickerView.showsSelectionIndicator = YES; self.mPickerView.delegate = self; self.mPickerView.dataSource = self; [self.mPickerView setNeedsLayout]; self.mPickerView.transform = CGAffineTransformMakeScale(0.75f, 0.75f); self.mPickerView.hidden = TRUE; [self.view addSubview:self.mPickerView]; lblType.text = [arrType objectAtIndex:indexPath.row]; if([arrCost count] == 0) { lblPrice.text = @"0"; } else{ lblPrice.text = [arrCost objectAtIndex:indexPath.row]; } [cell addSubview:lblType]; [cell addSubview:lblPrice]; [cell addSubview:btnPicker]; [cell addSubview:lblSeat]; return cell; } -(NSInteger) numberOfComponentsInPickerView:(UIPickerView *)pickerView { return 1; } -(NSInteger) pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { return 10; } -(NSString *) pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { return [numbers objectAtIndex:row]; } -(void) pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { strSelected = [numbers objectAtIndex:row]; NSLog(@"str selection:%@", strSelected); self.mPickerView.hidden = TRUE; [self.mTicketTable reloadData]; } </code></pre> <p>Please guide for the above.</p> <p>Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload