Ios4 UITapGestureRecognitor在Xcode 4.1/iOS 4.3上不工作

Ios4 UITapGestureRecognitor在Xcode 4.1/iOS 4.3上不工作,ios4,uibutton,uitableview,uitapgesturerecognizer,xcode4.1,Ios4,Uibutton,Uitableview,Uitapgesturerecognizer,Xcode4.1,我正在尝试实现一个可扩展的表视图单元,使用以下示例: 在这里,他们使用的是Xcode 4.3和iOS 5,但我必须使用Xcode 4.1和iOS 4.3来实现它。使用这个版本,我的视图/按钮在点击按钮时无法识别,但我使用相同的类编译了我的项目,但使用的是Xcode 4.3/iOS 5,点击按钮可以识别,因此类很好 下面是使用按钮创建UIView的代码: 截面视图.m -(id)initWithFrame:(CGRect)frame withTitle:(NSString *)title sec

我正在尝试实现一个可扩展的表视图单元,使用以下示例:

在这里,他们使用的是Xcode 4.3和iOS 5,但我必须使用Xcode 4.1和iOS 4.3来实现它。使用这个版本,我的视图/按钮在点击按钮时无法识别,但我使用相同的类编译了我的项目,但使用的是Xcode 4.3/iOS 5,点击按钮可以识别,因此类很好
下面是使用按钮创建UIView的代码:
截面视图.m

-(id)initWithFrame:(CGRect)frame withTitle:(NSString *)title section:(NSInteger)sectionNumber delegate:(id<SectionView>)Delegate{
    self = [super initWithFrame:frame];
    if(self){
        UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(discButtonPressed:)];
        [tapGesture setNumberOfTapsRequired:1];
        tapGesture.cancelsTouchesInView = NO;
        [self addGestureRecognizer:tapGesture];

        self.userInteractionEnabled = YES;

        self.section = sectionNumber;
        self.delegate = Delegate;

        CGRect labelFrame = self.bounds;
        labelFrame.size.width -= 50;
        CGRectInset(labelFrame, 0.0, 5.0);

        UILabel *label = [[UILabel alloc] initWithFrame:labelFrame];
        label.text = title;
        label.font = [UIFont boldSystemFontOfSize:16.0];
        label.backgroundColor = [UIColor clearColor];
        label.textColor = [UIColor blackColor];
        label.textAlignment = UITextAlignmentLeft;
        [self addSubview:label];
        self.sectionTitle = label;

        CGRect buttonFrame = CGRectMake(labelFrame.size.width, 0, 50, labelFrame.size.height);
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.frame = buttonFrame;
        [button addTarget:self action:@selector(discButtonPressed:) forControlEvents:UIControlEventTouchUpInside];

        [self addSubview:button];
        self.discButton = button;
    }

    return self;
 }
我会非常感谢你的帮助。谢谢

#import <UIKit/UIKit.h>
#import "SectionView.h"

@interface TableDropViewController : UITableViewController <SectionView>

@end
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    SectionInfo *si = [self.sectionInfoArray objectAtIndex:section];
    if(!si.sectionView){
        NSString *title = si.category;
        si.sectionView = [[SectionView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.bounds.size.width, 45) withTitle:title section:section delegate:self];
    }
    return si.sectionView;
}