【问题标题】:scrollToRowAtIndexPath scroll inside the header sectionscrollToRowAtIndexPath 在标题部分内滚动
【发布时间】:2009-12-01 06:49:36
【问题描述】:

当我使用 indexpath.row = 0 时,它工作正常并显示在标题下方

但是当我使用 indexpath.row =1 时,第 1 行将在表格视图的标题部分内移动。

请帮帮我,我希望在 lauch 时隐藏第一行。

[alltweettableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO];

【问题讨论】:

    标签: iphone


    【解决方案1】:

    我猜您正在使用具有一定透明度/半透明性的默认表格标题(类似于联系人应用程序),因此第一行的底部显示在那里。

    查看 UITableViewDelegate 方法 tableView:viewForHeaderInSection 的文档,然后您可以在 tableView 的委托中实现该方法。向它发送一个具有非半透明(或透明)背景的视图,它应该防止顶行显示出来。

    首先,我会让它直接返回一个带有纯白色背景的自定义大小的 UILabel,并确保它可以正常工作(因为我还没有对此进行测试:)

    // you'd probably need to fill in the frame sizes yourself // so try something other than CGRectZero at first. // for example (10,2,320,30) to start, then go from there #define X 10 #define Y 2 #define WIDTH 320 #define HEIGHT 30 -(UIView*)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section { UILabel *sectionHeader = [[UILabel alloc] initWithFrame:CGRectMake(X,Y,WIDTH,HEIGHT)]; sectionHeader.text = [NSString stringWithFormat:@"Section %d",section]; sectionHeader.background = [UIColor whiteColor]; return [sectionHeader autorelease]; }

    假设这有效并且看起来像进步,您可能希望编写一个自定义视图返回它作为下一步。

    【讨论】:

      猜你喜欢
      • 2012-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-09
      • 1970-01-01
      • 2023-03-26
      • 2017-07-14
      相关资源
      最近更新 更多