答案 0 :(得分:0)
您可以使用tableHeaderView
进行此类工作。
在viewDidLoad
下面写下代码。
- (void)viewDidLoad
{
**// Take one view and subview that view in the tableview.**
UIView *viewsearch=[[UIView alloc]initWithFrame:CGRectMake(0,-10, 320,83)];
[self.Yourtablename addSubview:viewsearch];
**//Now take any controls which you want to show in your header. e.x label,button,searchbar**
UILabel *lbl1 = [[UILabel alloc] init];
[lbl1 setFrame:CGRectMake(0,5,100,20)];
lbl1.backgroundColor=[UIColor clearColor];
lbl1.textColor=[UIColor whiteColor];
lbl1.userInteractionEnabled=YES;
[viewsearch addSubview:lbl1];
lbl1.text= @"BUY THE NEW APPLE TV FROM THE APPSTORE";
**//Here is the code.With the help of this code when you scroll UP the headerview hide.**
self.tbluser.tableHeaderView = viewsearch;
self.tbluser.contentOffset = CGPointMake(0, CGRectGetHeight(viewsearch.frame));
}
可能会帮助你。