ios uitableview ios4 uiscrollview uipagecontrol

ios - ¿Es posible usar UIPageControl para controlar el movimiento de UITableView?



ios4 uiscrollview (1)

Seguro que es posible, pero ¿por qué querrías esto? Una vista de tabla se desplaza verticalmente, mientras que un control de página tiene un diseño horizontal, por lo que probablemente se vea / se sienta raro.

De todos modos, si realmente desea hacer esto, agregue su controlador de vista como un objetivo del control de página:

[pageControl addTarget:self action:@selector(pageChanged:) forControlEvents:UIControlEventValueChanged];

Luego implementa el desplazamiento en la acción:

- (void)pageChanged:(UIPageControl *)sender { float scrollPosition = ((float)sender.currentPage / (float)sender.numberOfPages) * tableView.contentSize.height; [tableView scrollRectToVisible:CGRectMake(0, scrollPosition, 1, 1) animated:YES]; }

De la muestra de Apple "PageControl" podemos saber que UIPageControl se puede usar para controlar el movimiento de las páginas en scrollview.

Como UITableView es la subclase de UIScrollView, quiero usar UIPageControl para controlar el movimiento de la celda de vista de tabla al igual que en "PageControl".

Pero no puedo encontrar ninguna interfaz de delegado para que yo haga eso.

La pregunta es :

¿Es posible hacer esto? Y por qué ?

Gracias

Déjame responder mi pregunta con:

Seleccionar y desplazarse mediante programación

Listado 6-5 Seleccionar programáticamente una fila

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)newIndexPath { NSIndexPath *scrollIndexPath; if (newIndexPath.row + 20 < [timeZoneNames count]) { scrollIndexPath = [NSIndexPath indexPathForRow:newIndexPath.row+20 inSection:newIndexPath.section]; } else { scrollIndexPath = [NSIndexPath indexPathForRow:newIndexPath.row-20 inSection:newIndexPath.section]; } [theTableView selectRowAtIndexPath:scrollIndexPath animated:YES scrollPosition:UITableViewScrollPositionMiddle]; }