UIButton in a UITableView header ignores most touches

前端 未结 9 2509
盖世英雄少女心
盖世英雄少女心 2020-12-28 18:58

I\'ve got a button that I\'m adding as a subview of a table view\'s tableHeaderView. The button appears fine, and tap-and-holding on it works intermittently - for the most p

9条回答
  •  粉色の甜心
    2020-12-28 19:19

    tableHeaderView has 0 height while it is processing draw in UITableView

    use this UIView subclass to set the strong constant height and ignore UITableView processing

    #import                                                 
    @interface CustomHeaderCell : UIView
    
    @end  
    
    //-----
    
    @import "CustomHeaderCell.h"
    
    @implementation CustomHeaderCell
    
    
    -(void)setFrame:(CGRect)frame {
        frame.size.height = 43; // !!! constant height
        [super setFrame:frame];
    }
    
    @end
    

提交回复
热议问题