开发者

an UIButton in an UIPickerView doesn't respond to click event

i add an UIButton to an UIPicker view bu this code

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

}

but when i click on an uibutton this doesn't respond. where was my mistake? Thks.开发者_运维百科


Just try explicitly changes userInteractionEnabled=YES for button also, may that can be a case here.


Allocate memory to your button.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜