开发者

uipickerviews inside table cell not selectable

I have a table cell for which I set its contentView to a custom view that contains one label and a number of uipickerviews. My problem is that only the 开发者_如何学运维first picker view is selectable, while all the rest are not. When I click on any of the not-selectable picker views, the table cell gets selected instead. Below is my code:


// Inside cellForRowAtIndexPath:
CustomPickerView *customView = [[CustomPickerView alloc] initWithFrame:CGRectMake(0, 0,
      cell.frame.size.width, 84) andCustomObject:customObject];
[customView setPickerViewSelection:@""];
[cell.contentView addSubview:customView];
[customView release];

// Inside CustomPickerView's initWithFrame:andCustomObject method:
for (...) {
   UIPickerView *tempPickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(25 + 
                 size.width,yPosition + 42, 320, frame.size.height - 22)];
   self.pickerView = tempPickerView;
   [tempPickerView release];
   self.pickerView.delegate = self;
   self.pickerView.dataSource = self;
   self.pickerView.showsSelectionIndicator = YES;
   CGAffineTransform t0 = CGAffineTransformMakeTranslation(pickerView.bounds.size.width/2, pickerView.bounds.size.height/2);
   CGAffineTransform s0 = CGAffineTransformMakeScale(0.4, 0.5);
   CGAffineTransform t1 = CGAffineTransformMakeTranslation(-pickerView.bounds.size.width/2, -pickerView.bounds.size.height/2);
   self.pickerView.transform = CGAffineTransformConcat(t0, CGAffineTransformConcat(s0, t1));

   [self addSubview:pickerView];
}

I also tried the route of creating an array of picker views instead of just one picker view, but it made no difference, which makes sense because when you add the picker view as a subview, that picker view is retained, so in the end, I always end up with x number of picker views in the custom view (custom view that will be added to the table cell's content view).

Thanks, Mihai


I didn't go through all the details of your code, but at the face of it, it sounds like you've put the control in too small a frame. The overflowing content will display (unless you explicitly prevent it, through clip subviews in IB) but your events will not reach the content.

try to set .clipsToBounds = YES and you'll know if this is your problem.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜