Come posso imitare questo comportamento in UITableView. In cui, se spingo il tavolo verso il basso, l'intestazione resta ferma, ma se faccio scorrere il tavolo verso l'alto, l'intestazione lo segue.
Mi piace l'app store. (scorrendo verso l'alto)
risposte:
0 per risposta № 1Puoi usare tableHeaderView
per questo tipo di lavoro.
Nel tuo viewDidLoad
scrivi sotto il codice.
- (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));
}
Forse ti aiuterà.