UIButton в UIPickerView не отвечает на событие нажатия - PullRequest
1 голос
/ 12 октября 2011

Я добавляю UIButton в представление UIPicker с помощью этого кода

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {


UIView *returnedView=(id)view;
if (!returnedView) {


returnedView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, [pickerView rowSizeForComponent:component].width, 44)];
}
returnedView.userInteractionEnabled=YES;


 UILabel   *retval=[[[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f,50, 44)] autorelease];
      retval.text = [[_figureArrayPicker objectAtIndex:row] valueForKey:@"FIGPic"];

      UIButton *button=[self  pieChartOfFigureWithCmm:row];
      [button setFrame:CGRectMake(50, 0, 50, 44)];
      [button addTarget:self action:@selector(defectPressed:) 
        forControlEvents:UIControlEventTouchUpInside];
          [returnedView addSubview:button];

  } 

[returnedView addSubview:retval];


return returnedView;

}

, но когда я нажимаю на uibutton, это не отвечает.где была моя ошибка?Thks.

Ответы [ 2 ]

0 голосов
/ 12 октября 2011

Выделите память для вашей кнопки.

0 голосов
/ 12 октября 2011

Просто попробуйте явно изменить userInteractionEnabled = YES для кнопки, может быть, это может быть случай здесь.

...