Iphone 按钮在UITableView的headerview上没有响应
我正在为我的tableview创建标题,并在标题上添加视图。 在该视图中有两个ImageView和一个按钮 按钮没有响应(顶部很小的区域有响应) 为什么会这样,请帮帮我 我尝试过一些这样的答案,比如“setAutoresizingMask:UIViewAutoResizingOne” 但一切都不起作用 这是我的密码Iphone 按钮在UITableView的headerview上没有响应,iphone,objective-c,uitableview,header,uibutton,Iphone,Objective C,Uitableview,Header,Uibutton,我正在为我的tableview创建标题,并在标题上添加视图。 在该视图中有两个ImageView和一个按钮 按钮没有响应(顶部很小的区域有响应) 为什么会这样,请帮帮我 我尝试过一些这样的答案,比如“setAutoresizingMask:UIViewAutoResizingOne” 但一切都不起作用 这是我的密码 -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
// ADDING A VIEW
UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 310, 39.0)];
header.backgroundColor = [UIColor clearColor];
header.userInteractionEnabled = YES;
[header setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
// ADDING IMAGE VIEW
UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 310, 39.0)];
image.image = [UIImage imageNamed:@"headertop.png"];
[image setUserInteractionEnabled:TRUE];
[header addSubview:image];
// ADDING ANOTHER IMAGEVIEW (beneath the view's frame)
UIImageView *downImage = [[UIImageView alloc]initWithFrame:CGRectMake(0 , 39, 310, 23)];
downImage.image = [UIImage imageNamed:@"headerbottom.png"];
[header addSubview:downImage];
// ADDING BUTTON
UIButton *placeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[placeBtn addTarget:self
action:@selector(goToRestPage:)
forControlEvents:UIControlEventTouchUpInside];
placeBtn.tag = section;
placeBtn.backgroundColor = [UIColor yellowColor];
placeBtn.frame = CGRectMake(75,20, 150, 20);
[header addSubview:placeBtn];
return header;
}
请这样做:
从XIB启用的用户交互为TRUE。默认情况下,它为FALSE
谢谢,请执行以下操作:
从XIB启用的用户交互为TRUE。默认情况下,它为FALSE
谢谢,请使用此方法。我想你错过了这个方法
-(float)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 30.0;
}
或者此方法已存在,因此请增加收割台的高度
-(float)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 80.0;
}
使用这种方法。我想你错过了这个方法
-(float)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 30.0;
}
或者此方法已存在,因此请增加收割台的高度
-(float)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 80.0;
}
哪个。。。??我在XIB中以编程方式创建所有内容,只有表格视图标题高度是多少?在哪个。。。??我在XIB中以编程方式创建所有内容只有表格视图标题高度是多少?