仅在 iOS 7 上有一个奇怪的 UIPickerView 问题
我有一个包含 3 行的 UIPickerView。每行都有一个按钮,其选择器已定义,但它从不响应按钮点击。
这是我的代码。
- (UIView *)pickerView:(UIPickerView *)pickerView
viewForRow:(NSInteger)row
forComponent:(NSInteger)component
reusingView:(UIView *)view {
NSLog(@"row %d", row);
if(view == nil) {
view = [[[UIView alloc] init] autorelease];
}
[view setFrame:CGRectMake(0, 0, 320, 44)];
UIButton *manageButton = (UIButton *)[view viewWithTag:TAG_MANAGE + row];
UILabel *descTypeLabel = (UILabel *) [view viewWithTag:TAG_DESCTYPE_LABEL + row];
if(manageButton == nil && row != 0) {
CGRect frame = CGRectMake(210, 7, 90, 30);
manageButton = [UIButton buttonWithType:UIButtonTypeCustom];
manageButton.frame = frame;
[manageButton setTitle:@"Manage" forState:UIControlStateNormal];
[manageButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[manageButton setBackgroundImage:[[UIImage imageNamed:@"blackButton.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(8, 8, 8, 8)] forState:UIControlStateNormal];
manageButton.tag = TAG_MANAGE + row;
[view addSubview:manageButton];
}
if(descTypeLabel == Nil) {
descTypeLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, 190, 44)];
descTypeLabel.backgroundColor = [UIColor clearColor];
descTypeLabel.tag = TAG_DESCTYPE_LABEL + row;
[descTypeLabel setText:[descTypes objectAtIndex:row]];
[view addSubview:descTypeLabel];
[descTypeLabel release];
}
//[manageButton addTarget:self action:@selector(managePressed:) forControlEvents:UIControlEventTouchUpInside];
[manageButton addTarget:self action:@selector(manageButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
return view;
}
-(void) manageButtonPressed : (UIButton *) sender {
//Not Called
}