【发布时间】:2013-11-10 16:44:42
【问题描述】:
我的(比较复杂的)情况如下:
-
TestView是UIScrollView的子类,它实现了-drawRect:,但在-drawRect:内部的某个时刻,它会调用一个方法,比如-drawAnotherPartWithRect:context:。此方法由TestView的子类实现,用于单独绘制上下文的某个部分。 -
TestView的两个子类实现了-drawAnotherPartWithRect:context:,目前它们在其中做同样的事情:Subclass1和Subclass2。 - 到目前为止,帧大小是两者在初始化期间的唯一区别。
Subclass1 的一个实例被用作表格视图的部分标题,它工作得很好,但是如果Subclass2 被用作单元格内容视图的子视图,它会显示,但不会滚动。其初始化如下:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PortoAppSubjectViewTableViewCell"];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"PortoAppSubjectViewTableViewCell"] autorelease];
Subclass2 *contentView = [[[Subclass2 alloc] initWithFrame:CGRectMake(0.f, 0.f, [tableView bounds].size.width, 32.f)] autorelease];
[contentView setContentSize:CGSizeMake(tableView.bounds.size.width * 3, 32.f)];
[contentView setTag:55];
[[cell contentView] addSubview:contentView];
}
[(SubjectTableViewCellContentView *)[[cell contentView] viewWithTag:55] setContainer:[[[[$container subGradeContainers] objectAtIndex:[indexPath section]] subGradeContainers] objectAtIndex:[indexPath row]]];
return cell;
}
有趣的是,水平滚动指示器出现并显示它滚动良好,但文本(使用 CoreText 绘制)并没有随之左右移动。 Subclass1 开箱即用。此外,如果将Subclass2 用作节标题视图的视图类,它将正常工作。
那么,水平滚动视图和表格视图单元格是怎么回事?我查看了关于 SO 的其他相关问题,但没有找到任何解决方案。
【问题讨论】:
标签: objective-c uitableview uiscrollview uikit