Header in storyboard for UITableViewController does not “stick”

蹲街弑〆低调 提交于 2019-12-11 05:14:17

问题


I have a UITableViewController that is in a storyboard. I want to add a header to it so I followed the instructions in the following post. I dragged a UIView up on top, and on top of that i dragged a couple of images.

Table Header Views in StoryBoards

Now that seemed to work fine, but the header scrolls along with the entries in table cells when i scroll up. Also, they seem to scroll underneath the time and battery indicator...not sure why that is.

So in the comments of that post i saw that you need to implement the following function to return the UiView to get it to "stick". The only way I saw how to get the UiView from the storyboard was to set the tag and then look it up, also shown below.

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section.
{
     int tagNumber = 2; 
     UIView *headerView = (UIView *)[self.view viewWithTag:tagNumber];
     return headerView;
}

The issue with all of this is the header still scrolls. How can i get the header view to just stay on top?

Thanks!

来源:https://stackoverflow.com/questions/20938998/header-in-storyboard-for-uitableviewcontroller-does-not-stick

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!