Вы должны добавить экземпляр UIScrollView в качестве подкласса ячейки tableView. .
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 30;}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 15) {
return 200;
}
return 44; }
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"Cell";
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
if (indexPath.row == 15) {
UIScrollView *scroll = [[[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 200)] autorelease];
scroll.backgroundColor = [UIColor greenColor];
scroll.contentSize = CGSizeMake(self.view.frame.size.width, 500);
[cell addSubview:scroll];
}
return cell; }
Затем вы можете установить contentOffset Tableview в viewDidLoad
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.tableView.contentOffset = CGPointMake(0, 400); }
Также вы можете создать пользовательскую ячейку с Scrollview по подклассов UITableViewCell. Лир, как настроить tableView ячейки в этом tutorial.
Если вы хотите, чтобы scrollview находилось над табличным представлением, почему вы делаете scrollview подвью в представлении таблицы? Вы должны сделать scrollview, а представление tableview - субвью общего представления родителя. – rmaddy
Я использую UITableViewController, поэтому у меня нет выбора, я думаю? – user1596328
Затем пользователь вместо 'UIViewController' и добавит scrollview и tableview в качестве подзаголовков. – rmaddy