buguibu / ios-notes-issues-lessons

Notes, issues and lessons about my iOS development experience
2 stars 0 forks source link

Table footer view #17

Open buguibu opened 4 years ago

buguibu commented 4 years ago

You can't add a footer view from a Nib with auto-layout and flexible height, or at least I didn't find the proper way, the height or Y position will be a mess. But this works for the header ¯_(ツ)_/¯

So the only way is add a subview directly to the tableview in the proper XIB/Storyboard, but you must take care of that the first subview you add will be the header, so if you dan't want a header set it to zero height, then add the footer.

If you ran into a mess you always can fix it by manually editing the XIB where you will find something like:

                            <tableView clipsSubviews="YES" contentMode="scaleToFill" ....>
                                <rect key="frame" x="0.0" y="302" width="414" height="560"/>
                               <view key="tableHeaderView" contentMode="scaleToFill" id="NAU-6c-eK8">
                                    <rect key="frame" x="0.0" y="818" width="414" height="0"/>
                                    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                    <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                </view>
                                <view key="tableFooterView" contentMode="scaleToFill" id="Cg6-iW-wJn">
                                    <rect key="frame" x="0.0" y="0.0" width="414" height="818"/>
                                    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                    <subviews>