ios - 自定义 Push Segue 移除 Storyboard中的导航栏和标签栏

标签 ios cocoa-touch ios7 segue uistoryboardsegue

我在自定义 Segue 中定义了以下内容,我们称它为 SegueX:

@interface SegueX : UIStoryboardSegue
@end

@implementation SegueX

- (void)perform
{
    CATransition* transition = [CATransition animation];

    transition.duration = 0.3;
    transition.type = kCATransitionFade;

    [[self.sourceViewController navigationController].view.layer addAnimation:transition forKey:kCATransition];
    [[self.sourceViewController navigationController] pushViewController:[self destinationViewController] animated:NO];
}

@end

在我的 Storyboard中,我刚刚将标准 Push segue 更改为 SegueX。出于某种原因,这将删除我的导航栏和标签栏。此外,我在 Storyboard中定义的所有 UIBarButtonItems 在运行时隐藏了自定义转场之后。我该如何解决?我希望它不是这样的......

在更改为自定义转场之前

Before changing to a custom segue

更改为自定义转场后

After changing to a custom segue

enter image description here

将其保存到 Main.storyboard

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="4514" systemVersion="13A603" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="aUj-3O-DdX">
    <dependencies>
        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3747"/>
    </dependencies>
    <scenes>
        <!--Navigation Controller-->
        <scene sceneID="prC-ky-DMz">
            <objects>
                <navigationController definesPresentationContext="YES" id="aUj-3O-DdX" sceneMemberID="viewController">
                    <navigationBar key="navigationBar" contentMode="scaleToFill" id="2Uu-Rm-RXH">
                        <autoresizingMask key="autoresizingMask"/>
                    </navigationBar>
                    <toolbar key="toolbar" opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="aOK-Kc-Mfz">
                        <rect key="frame" x="0.0" y="416" width="320" height="44"/>
                        <autoresizingMask key="autoresizingMask"/>
                    </toolbar>
                    <connections>
                        <segue destination="PDT-yG-B9z" kind="relationship" relationship="rootViewController" id="w27-w2-lcd"/>
                    </connections>
                </navigationController>
                <placeholder placeholderIdentifier="IBFirstResponder" id="fNx-r3-Dzg" userLabel="First Responder" sceneMemberID="firstResponder"/>
            </objects>
            <point key="canvasLocation" x="-65" y="-179"/>
        </scene>
        <!--View Controller-->
        <scene sceneID="kMj-Al-ZjY">
            <objects>
                <viewController id="PDT-yG-B9z" sceneMemberID="viewController">
                    <layoutGuides>
                        <viewControllerLayoutGuide type="top" id="RKt-BS-gn9"/>
                        <viewControllerLayoutGuide type="bottom" id="eFe-fv-bG6"/>
                    </layoutGuides>
                    <view key="view" contentMode="scaleToFill" id="JbT-x8-qhX">
                        <rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
                        <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                        <subviews>
                            <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fTw-C6-P3N">
                                <rect key="frame" x="137" y="269" width="46" height="30"/>
                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                <state key="normal" title="Button">
                                    <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
                                </state>
                                <connections>
                                    <segue destination="uMi-ds-4FY" kind="custom" id="mPL-yx-hFQ"/>
                                </connections>
                            </button>
                        </subviews>
                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
                    </view>
                    <navigationItem key="navigationItem" id="Im9-4G-4Ga"/>
                </viewController>
                <placeholder placeholderIdentifier="IBFirstResponder" id="qXF-QN-k3Z" userLabel="First Responder" sceneMemberID="firstResponder"/>
            </objects>
            <point key="canvasLocation" x="473" y="-177"/>
        </scene>
        <!--View Controller-->
        <scene sceneID="ca6-vg-B3h">
            <objects>
                <viewController id="uMi-ds-4FY" sceneMemberID="viewController">
                    <layoutGuides>
                        <viewControllerLayoutGuide type="top" id="jd0-A9-WOV"/>
                        <viewControllerLayoutGuide type="bottom" id="5VJ-sS-U1V"/>
                    </layoutGuides>
                    <view key="view" contentMode="scaleToFill" id="gJp-P2-rUC">
                        <rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
                        <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
                    </view>
                </viewController>
                <placeholder placeholderIdentifier="IBFirstResponder" id="pih-Kj-ioJ" userLabel="First Responder" sceneMemberID="firstResponder"/>
            </objects>
            <point key="canvasLocation" x="1003" y="-179"/>
        </scene>
    </scenes>
    <simulatedMetricsContainer key="defaultSimulatedMetrics">
        <simulatedStatusBarMetrics key="statusBar"/>
        <simulatedOrientationMetrics key="orientation"/>
        <simulatedScreenMetrics key="destination" type="retina4"/>
    </simulatedMetricsContainer>
</document>

最佳答案

当您更改 segue 时,导航栏和工具栏应该在 Storyboard中消失——这是正常的。您可以将底部栏的模拟指标更改为“半透明工具栏”,这会将其添加回去,因此您可以向其添加按钮(您只想更改模拟指标,而不是拖入另一个工具栏,这会添加第二个工具栏)。在运行时,您应该仍会看到两个栏及其按钮。

关于ios - 自定义 Push Segue 移除 Storyboard中的导航栏和标签栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20058701/

相关文章:

ios - 以编程方式完成时,SpriteKit 中没有任何内容加载到屏幕

ios - 如何制作一个基本的 swift 4 套接字 io 应用程序

iphone - 独特的隐形角色? objective-c

iphone - UINavigationBar 顶部的自定义 Logo ?

swift - Segue "show detail"在 iOS 7 中不起作用 - Swift

ios - 当我在 Xcode 上移动屏幕时,为什么我看到文本较晚?

ios - UILocalNotification具有重复一次的行为,例如在Messages App中

ios - 在 UIView(不是 MKMapView)中使用纬度/经度的最佳实践

ios - 直接链接到 iOS 7 中的应用商店应用程序

crash - iOS7-UITabBarController seletedIndex崩溃