¿Cómo puedo hacer lo siguiente en una UIViewController (que contiene un tableview como subvista)Cómo incrustar un UITableView en una UIScrollView
inicialmente tienen una UIViewController que muestra una sección de vista previa (UIView)
//Setup container for preview section
UIView *tempContainer = [[UIView alloc]initWithFrame:CGRectMake(0, 20, 320, 100)];
self.preview_answer_container = tempContainer;
self.preview_answer_container.backgroundColor = [UIColor clearColor];
[tempContainer release];
[self.view addSubview:self.preview_answer_container];
también he añadido un UITableView (y una barra de búsqueda) por debajo de
//setup tableview
UITableView *tempTable = [[UITableView alloc]initWithFrame:CGRectMake(0,44 ,320,self.view.frame.size.height - 44)];
self.tagFriendsTableView = tempTable;
self.tagFriendsTableView.delegate = self;
self.tagFriendsTableView.dataSource = self;
[tempTable release];
[self.view addSubview:self.tagFriendsTableView];
Con esta configuración, mi área de desplazamiento es pequeño (sólo área estática por debajo de la sección de vista previa)
¿Cómo puedo modificar mi código de tal manera que 1) que puede desplazarse a toda la página hacia arriba es decir, la sección de vista previa y tableview se desplazarán juntos 2) Desplazamiento en su conjunto se detendrá cuando la barra de búsquedas llega a la parte superior (por debajo de barra de navegación) (ver captura de pantalla), pero el contenido de la UITableView sigue siendo desplazable
EDIT:
Código agregado para la vista UIScroll. Sin embargo, nada ha cambiado para mí. ¿Qué pasa con mi código?
//setup scroll view
UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
//Search
UISearchBar *tempBar = [[UISearchBar alloc]initWithFrame:CGRectMake(0, 120 + 20, 320, 44)];
self.sBar = tempBar;
[tempBar release];
self.sBar.delegate = self;
self.sBar.tintColor = [UIColor colorWithHexString:@"#b6c0c7"];
self.sBar.placeholder = @"Search for FB and DM friends";
[scroll addSubview:sBar];
//setup tableview
UITableView *tempTable = [[UITableView alloc]initWithFrame:CGRectMake(0,144 + 20 + 20 ,320,self.view.frame.size.height - 144 - 20 - 20 - 44)];
self.tagFriendsTableView = tempTable;
self.tagFriendsTableView.delegate = self;
self.tagFriendsTableView.dataSource = self;
[tempTable release];
//Add the scroll view to the parent view
[scroll addSubview:self.tagFriendsTableView];
scroll.contentSize = CGSizeMake(self.view.frame.size.width, self.view.frame.size.height);
[self.view addSubview:scroll];
[scroll release];
Esto solo funciona para una vista de tabla con una sección. – SAHM
¿Puede algún cuerpo explicarme algo más? Por favor – RaviJSS