简体   繁体   English

删除Uitableviewcontroller上托管的Uitableview顶部或底部的视图?

[英]Remove view on top or bottom of Uitableview hosted on Uitableviewcontroller?

I am currently trying to remove the top or bottom view from my tableview but the size of the whole tableview isnt just right. 我目前正在尝试从表视图中删除顶视图或底视图,但整个表视图的大小并不恰到好处。 Here is what i did so far. 这是我到目前为止所做的。

  • Created a TableviewController inside the Storyboard 在故事板内部创建了TableviewController
  • Created a Class derived from UITableViewController and set everything up like delegate etc. 创建了一个从UITableViewController派生的类,并设置了诸如委托等的所有内容。
  • Dragged a view to the top of the tableview inside the Storyboard 将视图拖到情节提要内部的表格视图顶部
  • Created and connected an outlet named topview for this 为此创建并连接了一个名为topview的插座
  • In Viewwillappear i will remove that topview dependent of some value so i tried some things 在Viewwillappear中,我将删除依赖于某些值的topview,因此我尝试了一些操作
 -(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; if(foo){ [self.topView setHidden:YES]; // or [self.topView removeFromSuperview]; // or [self.topView setFrame:CGRectMake(0, 0, 0, 0)]; } } 

For example if i remove the view from superview the topview isnt available anymore but there is a big gap on top .. how can i remove this top view from my tableview without having this gap ? 例如,如果我从超级视图中删除视图,则顶视图不再可用,但顶部仍然有很大的空隙..如何在没有此间隙的情况下从桌面视图中删除该顶视图?

I put some Screenshots to describe my Problem: 我放了一些截图来描述我的问题:

我想更改俯视图的大小或完全删除它

在此处输入图片说明

If you put it inside the tableview it is probably the tableHeaderView. 如果将其放在tableview中,则可能是tableHeaderView。 Try this: 尝试这个:

self.tableView.tableHeaderView = nil;

Should remove the view and update the tableview accordingly. 应该删除该视图并相应地更新tableview。

[self.tableview reloadData]

删除topview后,或者如果您使用自动布局,则可以使用[self.view updateConstraints];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM