Swift故事板标题不会改变

时间:2019-07-08 05:07:24

标签: ios swift

我在Tab Bar Controller中嵌入了VC。 VC在情节提要中设置了标题“个人资料”,我将其更改为“菜单”。现在,在情节提要中,标题显示为“菜单”-但是在我运行项目时,标题显示为“配置文件”。在情节提要源中,为VC设置了title="Menu"

它恰好是演示情节提要,因此我可以在viewWillAppear中更改标题,此问题已解决,但是如果我想使用其他情节提要作为演示情节提要,这将是一个问题而不是解决。

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    self.title="Menu"
}

除了情节提要的title属性外,我还可以在哪里检查以确保未在其他位置(可能仅在运行时起作用)设置此属性。没有在任何地方的代码中设置

该问题被确定为另一个问题的重复。但是,正如我的第一句话中所述,我的VC嵌入在Tab Bar控制器中,并且我已经在代码示例中使用对建议的重复问题的答案中提供的代码。我不是想让它正常工作,而是要按照应有的方式工作

2 个答案:

答案 0 :(得分:1)

您可以尝试<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/ic_bg_gradient_next" android:orientation="vertical"> <ImageView android:layout_width="wrap_content" android:layout_height="50dp" android:src="@mipmap/image_ssb_main" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Login" android:textColor="@color/white" android:textSize="@dimen/_24sdp" android:textStyle="bold" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Login to your account" android:textColor="@color/white" android:textSize="@dimen/_12sdp" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/_8sdp" android:layout_marginTop="@dimen/_10sdp" android:layout_marginRight="@dimen/_8sdp" android:text="Email" android:textColor="@color/black" android:textSize="@dimen/_14sdp" /> <EditText style="@style/editText" android:layout_width="match_parent" android:layout_height="@dimen/_25sdp" android:layout_gravity="center" android:layout_margin="@dimen/_8sdp" android:background="@drawable/edit_text_background" android:hint="Your Email" android:inputType="textEmailAddress" android:maxLines="1" android:paddingLeft="@dimen/_8sdp" android:singleLine="true" android:textAppearance="@style/editText" android:textColor="#2C2C2C" android:textSize="@dimen/_14sdp" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="@dimen/_4sdp" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="@dimen/_10sdp" android:text="Password" android:textColor="@color/black" android:textSize="@dimen/_14sdp" /> <EditText style="@style/editText" android:layout_width="match_parent" android:layout_height="@dimen/_25sdp" android:layout_gravity="center" android:layout_margin="@dimen/_8sdp" android:background="@drawable/edit_text_background" android:hint="Your Password" android:inputType="textEmailAddress" android:maxLines="1" android:singleLine="true" android:textAppearance="@style/editText" android:textColor="#2C2C2C" android:textSize="@dimen/_14sdp" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="@dimen/_4sdp" android:orientation="vertical"> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#009688" android:text="Login" android:textAllCaps="false" android:textColor="@color/white" android:textSize="@dimen/_14sdp" /> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/_10sdp" android:background="@color/white_greyish" android:text="Sign up" android:textAllCaps="false" android:textColor="@color/black" android:textSize="@dimen/_14sdp" /> </LinearLayout> </LinearLayout>

答案 1 :(得分:1)

我实际上在main.strings中找到了它-在那里进行了更改,现在可以正确显示