iOS TabbarController覆盖内容

时间:2018-04-07 22:40:30

标签: ios xamarin.forms xamarin.ios

我有一个TabBarController,我在其中显示不同的页面。问题是,页面底部的TabBar不会限制选项卡内部的内容大小,而是覆盖它。有没有办法改变这种行为。更多信息:

  • 我使用Xamarin.iOS但是要启动TabBarController(使用Storyboard),但选项卡的内容是Xamarin Forms ContentPages。 (原生Xamarin表格)
  • 这是我的问题图片

enter image description here

编辑1 这是我用来初始化XF ContentPage的代码:

namespace Happimeter.iOS
{
    public partial class SurveyViewController : UINavigationController
    {
        public SurveyViewController (IntPtr handle) : base (handle)
        {
            //InitializeSurveyView is a XF ContentPage
            var formsPage = new InitializeSurveyView();
            var startSurveyVc = formsPage.CreateViewController();
            PushViewController(startSurveyVc, true);
            startSurveyVc.Title = formsPage.Title;

            //some code omitted for brevity

            NavigationBar.TintColor = UIColor.White;
        }
    }
}

我将viewController分配给Storyboard中的tabBarController。见下文:

Main.storyboard:

<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="49e-Tb-3d3" useSafeAreas="YES">
<device id="retina4_7" orientation="portrait">
    <adaptation id="fullscreen"/>
</device>
<dependencies>
    <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
    <capability name="Constraints to layout margins" minToolsVersion="6.0"/>
    <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
    <capability name="Safe area layout guides" minToolsVersion="9.0"/>
</dependencies>
<customFonts key="customFonts">
    <array key="HelveticaNeue.ttc">
        <string>HelveticaNeue</string>
    </array>
</customFonts>
<scenes>
    <!--About-->
    <!--Tab Bar Controller-->
    <scene sceneID="yl2-sM-qoP">
        <objects>
            <tabBarController storyboardIdentifier="tabViewController" id="49e-Tb-3d3" customClass="TabBarController" sceneMemberID="viewController">
                <nil key="simulatedBottomBarMetrics"/>
                <tabBar key="tabBar" contentMode="scaleToFill" id="W28-zg-YXA" clipsSubviews="YES">
                    <rect key="frame" x="0.0" y="618" width="375" height="49"/>
                    <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
                    <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
                </tabBar>
                <connections>
                    <segue id="83046" destination="82960" kind="relationship" relationship="viewControllers"/>
                    <segue id="91417" destination="91401" kind="relationship" relationship="viewControllers"/>
                    <segue id="96651" destination="96631" kind="relationship" relationship="viewControllers"/>
                    <segue id="100501" destination="95834" kind="relationship" relationship="viewControllers"/>
                </connections>
            </tabBarController>
            <placeholder placeholderIdentifier="IBFirstResponder" id="HuB-VB-40B" sceneMemberID="firstResponder"/>
        </objects>
        <point key="canvasLocation" x="0.0" y="0.0"/>
    </scene>
    <!--Browse-->
    <!--About-->
    <!--Items-->
    <!--Title-->
    <!--New Item-->
    <!--Login View Controller-->
    <!--Login View Controller-->
    <!--Login View Controller-->
    <!--View Controller-->
    <scene sceneID="82959">
        <objects>
            <navigationController id="82960" sceneMemberID="viewController" customClass="SurveyViewController">
                <navigationBar key="navigationBar" contentMode="scaleToFill" id="82962" translucent="NO">
                    <rect key="frame" x="0.0" y="20" width="375" height="44"/>
                    <autoresizingMask key="autoresizingMask"/>
                    <color key="barTintColor" colorSpace="calibratedRGB" red="0.18823529411764706" green="0.47843137254901963" blue="0.91764705882352937" alpha="1"/>
                    <textAttributes key="titleTextAttributes">
                        <color key="textColor" colorSpace="calibratedWhite" white="1" alpha="1"/>
                    </textAttributes>
                </navigationBar>
                <connections/>
                <tabBarItem key="tabBarItem" title="Item" id="83045"/>
                <simulatedTabBarMetrics key="simulatedBottomBarMetrics"/>
            </navigationController>
            <placeholder placeholderIdentifier="IBFirstResponder" id="82963" userLabel="First Responder" sceneMemberID="firstResponder"/>
        </objects>
        <point key="canvasLocation" x="-495" y="794"/>
    </scene>
    <scene sceneID="91400">
        <objects>
            <navigationController id="91401" sceneMemberID="viewController" customClass="MoodOverviewViewController">
                <navigationBar key="navigationBar" contentMode="scaleToFill" id="91403" translucent="NO">
                    <rect key="frame" x="0.0" y="20" width="375" height="44"/>
                    <autoresizingMask key="autoresizingMask"/>
                    <color key="barTintColor" colorSpace="calibratedRGB" red="0.18823529411764706" green="0.47843137254901963" blue="0.91764705882352937" alpha="1"/>
                    <textAttributes key="titleTextAttributes">
                        <color key="textColor" colorSpace="calibratedWhite" white="1" alpha="1"/>
                    </textAttributes>
                </navigationBar>
                <connections/>
                <tabBarItem key="tabBarItem" title="Item" id="91402"/>
                <simulatedTabBarMetrics key="simulatedBottomBarMetrics"/>
            </navigationController>
            <placeholder placeholderIdentifier="IBFirstResponder" id="91404" userLabel="First Responder" sceneMemberID="firstResponder"/>
        </objects>
        <point key="canvasLocation" x="726" y="-1558"/>
    </scene>
    <scene sceneID="95833">
        <objects>
            <navigationController id="95834" sceneMemberID="viewController" customClass="SettingsPageViewController">
                <navigationBar key="navigationBar" contentMode="scaleToFill" id="95836" translucent="NO">
                    <rect key="frame" x="0.0" y="20" width="375" height="44"/>
                    <autoresizingMask key="autoresizingMask"/>
                    <color key="barTintColor" colorSpace="calibratedRGB" red="0.18823529411764706" green="0.47843137254901963" blue="0.91764705882352937" alpha="1"/>
                    <textAttributes key="titleTextAttributes">
                        <color key="textColor" colorSpace="calibratedWhite" white="1" alpha="1"/>
                    </textAttributes>
                </navigationBar>
                <connections/>
                <tabBarItem key="tabBarItem" title="Item" id="95835"/>
                <simulatedTabBarMetrics key="simulatedBottomBarMetrics"/>
            </navigationController>
            <placeholder placeholderIdentifier="IBFirstResponder" id="95837" userLabel="First Responder" sceneMemberID="firstResponder"/>
        </objects>
        <point key="canvasLocation" x="959" y="-809"/>
    </scene>
    <scene sceneID="96630">
        <objects>
            <navigationController id="96631" sceneMemberID="viewController" customClass="BluetoothPageViewController">
                <navigationBar key="navigationBar" contentMode="scaleToFill" id="96633" translucent="NO">
                    <rect key="frame" x="0.0" y="20" width="375" height="44"/>
                    <autoresizingMask key="autoresizingMask"/>
                    <color key="barTintColor" colorSpace="calibratedRGB" red="0.18823529411764706" green="0.47843137254901963" blue="0.91764705882352937" alpha="1"/>
                    <textAttributes key="titleTextAttributes">
                        <color key="textColor" colorSpace="calibratedWhite" white="1" alpha="1"/>
                    </textAttributes>
                </navigationBar>
                <connections/>
                <tabBarItem key="tabBarItem" title="Item" id="96632"/>
                <simulatedTabBarMetrics key="simulatedBottomBarMetrics"/>
            </navigationController>
            <placeholder placeholderIdentifier="IBFirstResponder" id="96634" userLabel="First Responder" sceneMemberID="firstResponder"/>
        </objects>
        <point key="canvasLocation" x="1350" y="-809"/>
    </scene>
    <scene sceneID="97944">
        <objects>
            <navigationController id="97945" sceneMemberID="viewController" customClass="SignInViewController" storyboardIdentifier="SignInViewController">
                <navigationBar key="navigationBar" contentMode="scaleToFill" id="97947" translucent="NO">
                    <rect key="frame" x="0.0" y="20" width="375" height="44"/>
                    <autoresizingMask key="autoresizingMask"/>
                    <color key="barTintColor" colorSpace="calibratedRGB" red="0.18823529411764706" green="0.47843137254901963" blue="0.91764705882352937" alpha="1"/>
                    <textAttributes key="titleTextAttributes">
                        <color key="textColor" colorSpace="calibratedWhite" white="1" alpha="1"/>
                    </textAttributes>
                </navigationBar>
                <connections/>
                <tabBarItem key="tabBarItem" title="Item" id="97946"/>
                <simulatedTabBarMetrics key="simulatedBottomBarMetrics"/>
            </navigationController>
            <placeholder placeholderIdentifier="IBFirstResponder" id="97948" userLabel="First Responder" sceneMemberID="firstResponder"/>
        </objects>
        <point key="canvasLocation" x="2905" y="-16"/>
    </scene>
</scenes>
<resources>
    <image name="First" width="32" height="30"/>
    <image name="HappimeterLogo" width="261" height="48"/>
    <image name="Second" width="32" height="30"/>
    <image name="XamarinLogo" width="220" height="51"/>
    <image name="happinessfactory" width="202" height="114"/>
</resources>

2 个答案:

答案 0 :(得分:0)

file2

答案 1 :(得分:0)

这对我有用:

class TabBarController: UITabBarController {

override func viewDidLoad() {
    super.viewDidLoad()
    
    tabBar.isTranslucent = false
}
相关问题