¿Por qué mi UITableView no ocupa los límites de la pantalla?
-
03-07-2019 - |
Pregunta
Estoy construyendo un UITableView programáticamente sin archivos NIB aquí. Sin embargo, estoy haciendo algo tonto, ya que mi barra de navegación se muestra bien, al igual que mi UITableView. Sin embargo, el UITableView no encaja correctamente en la pantalla. Verá aproximadamente 20 píxeles que separan la barra de navegación de UIN y la vista de UITable. Configuré el color de fondo de mi ventana en negro, como se puede ver en esta captura de pantalla:
Aquí está el código para reproducir el problema:
- (void)loadView
{
[super loadView];
// TableViews that wish to utilize tableView footers/headers should override this method.
UITableView *aTableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame] style:UITableViewStylePlain];
aTableView.autoresizingMask = (UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight);
aTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
aTableView.delegate = self;
aTableView.dataSource = dataSource;
self.tableView = aTableView;
[self.view addSubview:self.tableView];
[aTableView release];
// style navigation bar.
//self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
}
Solución
usa límites en lugar de applicationFrame
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow