【问题标题】:How to remove the white space in UITableview scroll in the iphone landscape mode?如何在iphone横向模式下删除UITableview滚动中的空白?
【发布时间】:2013-01-07 22:38:22
【问题描述】:

在我的 tableview 中,我禁用了 portrait 模式下的默认滚动。但是当方向更改为 landscape 模式时,我启用了滚动,以便我可以查看表格的全部内容。但是,当滚动时,在表格视图单元格之前和之后可以看到 空白。那么,谁能告诉我如何在横向模式下删除表格默认滚动视图中的这个空白? 我尝试过使用autoresizingmask,并尝试根据横向模式设置表格的内容大小。两者都没有工作,这是我到目前为止的代码。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

{

    // Return YES for supported orientations

    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);

  }

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {

if((self.interfaceOrientation == UIDeviceOrientationLandscapeLeft) || (self.interfaceOrientation == UIDeviceOrientationLandscapeRight)){

        self.tableView.scrollEnabled = YES;

        self.tableView.sectionIndexMinimumDisplayRowCount =5;

       self.tableView.contentSize = CGSizeMake(480, 320);

        self.tableView.autoresizingMask = YES;

       //CGFloat cellHeight;}

    else if((self.interfaceOrientation == UIDeviceOrientationPortrait) || (self.interfaceOrientation == UIDeviceOrientationPortraitUpsideDown)){

        self.tableView.scrollEnabled = NO;

        }
  }

【问题讨论】:

  • 必须尝试将tableview的背景颜色设置为clearcolor?

标签: iphone objective-c uitableview scroll landscape


【解决方案1】:

在 didRotateFromInterfaceOrientation 方法中试试这个,

[self.tableView setBounces: NO];

它会阻止滚动条弹跳并移除空白区域。

【讨论】:

    【解决方案2】:

    将单元格分隔符设置为无并将背景颜色设置为 clearColor。确保将 scrollView 样式设置为默认值。

    【讨论】:

    • 通过上面的答案让它工作。如果我将它设置为clearcolor,它会使空白区域变为黑色。我想要的是删除空间,无论它是什么颜色。无论如何感谢您的回答。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-10
    • 2011-03-02
    • 1970-01-01
    相关资源
    最近更新 更多