Sto provando a spostare UIRefreshControl sopra il mio headerView o almeno a farlo funzionare con contentInset. Qualcuno sa come usarlo?UITableView e UIRefreshControl
Ho usato un headerView per avere uno sfondo piacevole quando si scorre all'interno di TableView. Volevo avere uno sfondo scorrevole.
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
// Set up the edit and add buttons.
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.backgroundColor = [UIColor clearColor];
[self setWantsFullScreenLayout:YES];
self.tableView.contentInset = UIEdgeInsetsMake(-420, 0, -420, 0);
UIImageView *top = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"top.jpg"]];
self.tableView.tableHeaderView = top;
UIImageView *bottom = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bottom.jpg"]];
self.tableView.tableFooterView = bottom;
UIBarButtonItem *leftButton = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"settingsIcon"] style:UIBarButtonItemStylePlain target:self action:@selector(showSettings)];
self.navigationItem.leftBarButtonItem = leftButton;
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addList)];
self.navigationItem.rightBarButtonItem = addButton;
//Refresh Controls
self.refreshControl = [[UIRefreshControl alloc] init];
[self.refreshControl addTarget:self action:@selector(refreshInvoked:forState:) forControlEvents:UIControlEventValueChanged];
}
All'interno di un normale UIViewController non hai self.refreshControl, quindi hai completamente sbagliato lensovet – Godfather
ottimo consiglio ... thx – paiego
Questo metodo ha alcuni problemi se il tuo tableview ha una vista titolo (almeno su iOS7). Quando si scorre verso il basso durante l'aggiornamento, le sezioni della tabella diventano tutte fuori posto, compensate dall'altezza della vista del titolo. – AlBeebe