Как встроить UITableView в UIScrollview

Как я могу сделать следующее в UIViewController (содержащий табличное представление в качестве подпредставления)

У меня изначально есть UIViewController, показывающий раздел предварительного просмотра (UIView)

<code>//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];
</code>

Я также добавил UITableView (и панель поиска) ниже

<code>//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];
</code>

enter image description here

При такой настройке моя область прокрутки мала (только статическая область ниже раздела предварительного просмотра)

Как я могу изменить свой код так, чтобы 1) Я могу прокрутить всю страницу вверх, т.е. раздел предварительного просмотра и просмотр таблицы будут прокручиваться вместе 2) Прокрутка в целом остановится, когда панель поиска достигнет вершины (ниже панели навигации) (см. Скриншот), но содержимое в UITableView все еще можно прокручивать

enter image description here

РЕДАКТИРОВАТЬ:

Добавлен код для просмотра UIScroll. Однако для меня ничего не изменилось. Что не так с моим кодом?

<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];
</code>

Ответы на вопрос(6)

Ваш ответ на вопрос