我正在爲我的tableview創建標題,並在該標題上添加視圖。 在該視圖中,有兩個圖像瀏覽和一個按鈕按鈕不響應UITableView的headerview
該按鈕沒有響應(頂部非常小的區域是響應) 爲什麼發生這種情況,請幫助我?
我試圖與一些所謂的答案,如 「setAutoresizingMask:UIViewAutoresizingNone」 但沒有什麼工作
這裏是我的代碼
-(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中只有表格視圖 –
正常...那麼它應該工作 – sagarcool89
它不起作用.. –