How to remove a Static Cell from a UITableView designed in StoryBoard

前端 未结 9 2484
情话喂你
情话喂你 2020-12-13 09:43

The solution is probably very simple, but I couldn\'t just find it .. !

Working with storyboard (iOS 5), I have a tableViewController, and a designed ST

9条回答
  •  南方客
    南方客 (楼主)
    2020-12-13 10:01

    FYI (would comment if I could), if you are overriding a Grouped static UITableView from the Storyboard, then you'll also need to override the Header & Footer views & heights for each section you are modifying/hiding.

    I also needed to set the return value for the "GetHeight" methods to something other than zero - implying that a zero value means something else (autolayout, or "not set" or the like).

    The below code is in Xamarin iOS C#, but translates directly to the appropriate Obj-C methods:

        public override void WillDisplayHeaderView(UITableView tableView, UIView headerView, nint section)
        {
            if (section == 0)
            {
                headerView = new UIView(new CGRect(0,0,0,0));
            }
        }
    
        public override nfloat GetHeightForHeader(UITableView tableView, nint section)
        {
            if (section == 0)
            {
                return 1f;
            }
            return base.GetHeightForHeader(tableView, section);
        }
    
        public override void WillDisplayFooterView(UITableView tableView, UIView footerView, nint section)
        {
            if (section == 0)
            {
                footerView = new UIView(new CGRect(0, 0, 0, 0));
            }
        }
    
        public override nfloat GetHeightForFooter(UITableView tableView, nint section)
        {
            if (section == 0)
            {
                return 1f;
            }
            return base.GetHeightForFooter(tableView, section);
        }
    

提交回复
热议问题