Comment puis-je faire ce qui suit dans un UIViewController (contenant un tableview comme sous-vue)Comment intégrer une UITableView dans un UIScrollView
J'ai d'abord un UIViewController montrant une section d'aperçu (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];
J'ai aussi ajouté un UITableView (et un searchbar) ci-dessous
//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];
Avec cette configuration, ma zone de défilement est faible (seule zone statique ci-dessous section aperçu)
Comment puis-je modifier mon code tel que 1) je peux faire défiler toute la page vers le haut-à-dire la section d'aperçu et tableview défileront tous ensemble 2) Scrolling dans son ensemble s'arrête lorsque la barre de recherche atteint le sommet (ci-dessous navbar) (voir capture d'écran), mais le contenu du UITableView est encore scrollable
EDIT:
Code ajouté pour la vue UIScroll. Cependant, rien n'a changé pour moi. Quel est le problème avec mon code?
//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];
Cela ne fonctionne que pour une tableView avec une section. – SAHM
Quelqu'un peut-il expliquer plus pour moi? S'il vous plaît – RaviJSS