Iphone 添加为footerview时,UIButton没有响应

Iphone 添加为footerview时,UIButton没有响应,iphone,ios,uitableview,ios4,uibutton,Iphone,Ios,Uitableview,Ios4,Uibutton,我的按钮没有响应触摸事件,请查找下面的代码片段 我已将ui按钮添加到ui视图,并将ui视图设置为ui表格视图的页脚视图 请让我知道,谢谢 CGRect tblViewFrame = CGRectMake(self.view.bounds.origin.x, self.view.bounds.origin.y, self.view.bounds.size.width, 300); self.tblViewSettings = [[[UITableView alloc]initWithFrame:

我的按钮没有响应触摸事件,请查找下面的代码片段

我已将
ui按钮
添加到
ui视图
,并将
ui视图
设置为
ui表格视图的
页脚视图

请让我知道,谢谢

CGRect tblViewFrame = CGRectMake(self.view.bounds.origin.x, self.view.bounds.origin.y, self.view.bounds.size.width, 300);

self.tblViewSettings = [[[UITableView alloc]initWithFrame:tblViewFrame style:UITableViewStyleGrouped]autorelease];
self.tblViewSettings.backgroundColor = [UIColor clearColor];
self.tblViewSettings.showsVerticalScrollIndicator = FALSE;
self.tblViewSettings.delegate = self;
self.tblViewSettings.dataSource = self;
self.tblViewSettings.scrollEnabled = YES;

// Set the background color
self.view.backgroundColor = [UIColor clearColor];

UIView *buttonView = [[[UIView alloc]initWithFrame:CGRectMake(10,10, 320, 60)]autorelease];
self.signoutButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
self.signoutButton.frame = CGRectMake(10,10, 300, 40);
UIImage *image = [[UIImage imageNamed:@"btn-large1.png"] stretchableImageWithLeftCapWidth:22 topCapHeight:0];
NSString *strSignOut = NSLocalizedString(@"Sign Out", @"SignOut Button");
[self.signoutButton setTitle:strSignOut forState:UIControlStateNormal];
[self.signoutButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
self.signoutButton.titleLabel.shadowOffset = CGSizeMake(0, -1);
[self.signoutButton setBackgroundImage:image forState:UIControlStateNormal];
self.signoutButton.titleLabel.font = [UIFont boldSystemFontOfSize:20.0];
[self.signoutButton addTarget:self action:@selector(signOutBtnTapped:) forControlEvents:UIControlEventTouchUpInside];

buttonView.backgroundColor = [UIColor clearColor];

[buttonView addSubview:self.signoutButton];
buttonView.userInteractionEnabled = YES;
//[self.view addSubview:buttonView];
self.tblViewSettings.tableFooterView = buttonView;

self.tblViewSettings.tableFooterView.userInteractionEnabled = YES;

[self.view addSubview:self.tblViewSettings];

-(IBAction)signOutBtnTapped:(id)sender{
}

尝试捕获
UIControlEventTouchDown
的事件,而不是中的
UIControlEventTouchUpInside

[self.signburatton addTarget:self action:@selector(signOutBtnTapped:)for controlEvents:UIControlEventTouchUpInside]


其他一切似乎都正常。

用于在页脚视图部分添加按钮

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
UIView* customView;

customView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 60.0)];

UIButton *Login_Btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [Login_Btn setImage:[UIImage imageNamed:@"btn_login.png"] forState:UIControlStateNormal];

Login_Btn.frame = kiPhoneButtonFrame;

[customView addSubview:Login_Btn];
[Login_Btn addTarget:self 
                      action:@selector(Login_Btn_Clicked:)
            forControlEvents:UIControlEventTouchUpInside];

return customView;
}
点击按钮法

-(IBAction)Login_Btn_Clicked:(id)sender
{
     // Code for button CLick which you want to do.
}

我已经看过你的代码,并将其应用到我的项目中。事实上它是有效的。我没有改变你的密码。我想你必须检查表视图和底部视图的框架,因为其他一切都正常工作。

你能显示SignoutBtnattap的定义吗?@rishi:-(iAction)SignoutBtnattap:(id)发送方{注释掉背景图像线和阴影偏移线并检查。您是否能够滚动表格?还有一件事,您可以使用touch方法,并查看控件是否在那里?在这种情况下-(CGFloat)tableView:(UITableView*)tableView heightForHeaderInSection:(NSInteger)节;也必须实现,这里需要的是表页脚而不是节页脚。然后您可以使用-(CGFloat)tableView:(UITableView*)tableView heightforfooterInstruction:(NSInteger)节;其中只返回(页脚节的高度)Simple。有简单的实现。