iphone uitableview ios5 footer

iphone - Ocultar vista de pie de página en UITableView



ios5 footer (5)

He estado trabajando para ocultar la vista de pie de página por un tiempo. Mi problema es que tengo un botón en el pie de página cuando hago clic en el botón, una sección se agregará debajo como la última sección y el botón también cambiará a la sección recién creada y ahora quiero ocultar el pie de página en la sección anterior de la tabla después de la actualización de las secciones.

footerView.hidden = YES

Lo usé en la acción del botón pero no funciona.


Esto debería hacerlo

tableView.tableFooterView.hidden = YES;


Esto puede hacerlo implementando el método delegado

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { return CGFLOAT_MIN; }


Cuando no se usan vistas personalizadas, devuelve nil desde tableView:titleForFooterInSection: y 0 desde tableView:heightForFooterInSection:

@property(nonatomic, strong) NSString *footerTitle; @property(nonatomic, assign) BOOL shouldHideFooter;

- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section { return self.shouldHideFooter ? nil : self.footerTitle; } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { return self.shouldHideFooter ? 0 : UITableViewAutomaticDimension; }


Solución Swift 3.0 que también elimina el molesto límite de 1px entre la celda anterior y el siguiente encabezado.

override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { return CGFloat.leastNormalMagnitude } override func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? { return nil }


Hay cuatro soluciones. Son,

Solución 1:

tableView.sectionHeaderHeight = 0.0; tableView.sectionFooterHeight = 0.0; - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger )section { return 1.0; } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger )section { return 1.0; } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger )section { return [[UIView alloc] initWithFrame:CGRectZero]; } - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger )section { return [[UIView alloc] initWithFrame:CGRectZero]; }

Solución 2:

Puede establecer la altura del pie de página / encabezado a través del constructor de interfaz en la pestaña de tamaño.

Solución 3:

establecer la propiedad contentInset .

self.tableView.contentInset = UIEdgeInsetsMake(-20, 0, -20, 0);

Se usa para hacer que la parte superior e inferior toquen el borde.

Solución 4:

Implemente lo siguiente, establezca los valores según su condición. 0.0 no será aceptado. El valor más bajo debería ser 1.0.

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger )section { if(section == 0) { return 6; } else { return 1.0; } } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger )section { return 5.0; } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger )section { return [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)]; } - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger )section { return [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)]; }