UIButton addTarget不';不适用于iOS7,但适用于IOS6

UIButton addTarget不';不适用于iOS7,但适用于IOS6,ios,ios7,uibutton,uipickerview,Ios,Ios7,Uibutton,Uipickerview,显然,这段代码在iOS 6中有效。顺便说一下,它在iOS 7中有问题 我将UIButton添加到UIPickerView中的每一行: - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view { UIButton *btnRow=[UIButton buttonWithTyp

显然,这段代码在iOS 6中有效。顺便说一下,它在iOS 7中有问题

我将UIButton添加到UIPickerView中的每一行:

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
    UIButton *btnRow=[UIButton buttonWithType:UIButtonTypeSystem];
    [btnRow addTarget:self action:@selector(touch:) forControlEvents:UIControlEventTouchUpInside];
    btnRow.frame=CGRectMake(0, 0, 320, 30);
    int tag= selfTextField.tag/10000 - 1;
    [btnRow setTitle:[[pickerArray objectAtIndex:tag] objectAtIndex:row] forState:UIControlStateNormal];

    return btnRow;
}

不能在选择器视图行上放置按钮。因此,我在UIPickerView上方添加了一个工具栏,并在其上添加了一个bar按钮项。我使用行号通过选择器执行所需的功能

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
     ....
     //get the row number & Perform desired functionality
     ....
}

您将获得行号并使用它执行所需的功能。

您不能在选择器视图行上放置按钮。因此,我在UIPickerView上方添加了一个工具栏,并在其上添加了一个bar按钮项。我使用行号通过选择器执行所需的功能

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
     ....
     //get the row number & Perform desired functionality
     ....
}

您将获得行号并使用它执行所需的功能。

EDIT:DUPLICATE这是一个更好的副本,尽管没有真正的答案:。为什么不改为使用表视图?addSubview:btnRow方法在哪里?一些UITextFields应该由用户选择,包括一些日期。因此,我使用UIDatePicker和UIPickerView.EDIT:DUPLICATE这是一个更好的副本,但没有真正的答案:。为什么不改为使用表视图?addSubview:btnRow方法在哪里?一些UITextFields应该由用户选择,包括一些日期。因此,我使用UIDatePicker和UIPickerView。但它在IOS6中工作。我只想知道是什么导致了问题。所需的功能对所选行进行签名,并在UITextView中显示所选行的内容。因此,委托函数无法解决我的问题。此外,如何在UIPickerView上方添加工具栏并保持UIPickerView正常工作。在每一行上添加工具栏?但它在IOS6中工作。我只想知道问题的原因。所需的功能对所选行进行签名,并在UITextView中显示所选行的内容。因此,委托函数无法解决我的问题。此外,如何在UIPickerView上方添加工具栏并保持UIPickerView正常工作。在每行添加工具栏?