iOS7中的pickerview委托方法viewForRow中不调用Button动作?

时间:2014-08-27 07:06:01

标签: iphone ios7 xcode5 uipickerview

在我的应用程序中,我在选择器上添加了自定义视图,该选项器具有标签和带有目标方法的按钮,但是当我点击按钮方法时不调用。 这是我的代码 -

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{
   UIView *customView = [[UIView alloc]initWithFrame:CGRectMake(0,0,320,35)];
   UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(2,1,280,33)];
   [lbl setText:[arrPicker objectAtIndex:row]];
   [lbl setTextAlignment:NSTextAlignmentCenter];
   [lbl setBackgroundColor:[UIColor blueColor]];
   [customView addSubview:lbl];
   UIButton *btnPicker = [UIButton buttonWithType:UIButtonTypeCustom];
   [btnPicker setFrame:CGRectMake(285,3,29,29)];
   [btnPicker setBackgroundImage:[UIImage imageNamed:@"btn_radio_uncheked.png"] forState:UIControlStateNormal];
   [customView setUserInteractionEnabled:YES];
   [btnPicker setUserInteractionEnabled:YES];
   [btnPicker setTag:row];
   [btnPicker addTarget:self action:@selector(btnCheckPicker:) forControlEvents:UIControlEventTouchUpInside];
   [customView addSubview:btnPicker];
   return customView;
}

- (void)btnCheckPicker:(UIButton *)btn{
   NSLog(@"PickerButtonAction");
}

0 个答案:

没有答案