请查看我的截图,蓝色"返回"文本总是显示在iphone plus上(6s plus,7 plus加上模拟器和真实设备)。它没有在较小的屏幕iphone上显示。我尝试了很多方法来隐藏/改变它从现在/以前的控制器,但没有运气。
那为什么它适用于较小的iphone但不适用于加号?
任何人都可以帮助我:(。谢谢。
以下是代码:
@IBAction func filter(_ sender: Any) {
let view:FilterViewController = self.storyboard?.instantiateViewController(withIdentifier: "FilterViewController") as! FilterViewController
view.superVC = self
view.currentFilter = currentFilter
self.setLeftCloseNavigation()
self.navigationController?.pushViewController(view, animated: true)
}
func setLeftCloseNavigation(){
self.navigationController?.navigationBar.backgroundColor = UIColor.clear
self.navigationController?.navigationBar.isTranslucent = true
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationController?.navigationBar.layer.mask = nil
self.navigationController?.navigationBar.backIndicatorImage = UIImage(named: "icon_close")?.withRenderingMode(.alwaysOriginal)
self.navigationController?.navigationBar.backIndicatorTransitionMaskImage = UIImage(named: "icon_close")?.withRenderingMode(.alwaysOriginal)
navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil)
}
这是推送控制器中的viewDidLoad:
override func viewDidLoad() {
super.viewDidLoad()
statusBar = UIColor.black
setResetNavigation() }
func setResetNavigation(){
navigationItem.hidesBackButton = false
let skipButton = UIButton(frame: CGRect(x: 0, y: 0, width: 70, height: 30))
skipButton.setTitle("Reset all".localized(), for: .normal)
skipButton.setTitleColor(UIColor.black, for: .normal)
skipButton.titleLabel?.font = UIFont(name: "HJGothamMedium", size: 16)
skipButton.addTarget(self, action: #selector(resetAllClicked), for: .touchUpInside)
let skip = UIBarButtonItem(customView: skipButton)
navigationItem.rightBarButtonItem = skip
}
这是视图层次结构
答案 0 :(得分:2)
添加此功能:
<table align="center" bgcolor="#ffffff" border="0" cellpadding="3"
cellspacing="6" style="background-image: url(../Images/bar.jpg)"
width="900">
答案 1 :(得分:0)
试试这个
self.navigationItem.hidesBackButton = true
或检查您的故事板,它将保持
答案 2 :(得分:0)
使用以下行删除文字
navigationController?.navigationBar.topItem?.title = ""
答案 3 :(得分:0)
您可以检查UI层次结构,如果找到相关视图,则删除该视图:
您还可以通过从调试导航器中的流程视图选项菜单中选择“查看UI层次结构”,或选择调试&gt;来调用视图调试器。查看调试&gt;捕获视图层次结构。
答案 4 :(得分:0)
从下面的代码中,您可以将backButton文本颜色设置为您想要的任何颜色。您只需将backButton设置为clear
textColor即可。因此,它出现时不会被看到。
UIBarButtonItem.appearance(whenContainedInInstancesOf: [UINavigationBar.classForCoder() as! UIAppearanceContainer.Type]).setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.clear], for: .normal)
更新:如果您想采用其他方法。请查看此帖How to customize the navigation back symbol and navigation back text?并接受回答。
答案 5 :(得分:0)
要隐藏后面文本,您需要在视图控制器上将导航项标题设置为空格字符,以推送显示的视图控制器:
<p:column headerText="Register">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{dfAdmin.getMainGroupLabel(df.group.mainGroup.id)}" />
</f:facet>
<f:facet name="input">
<p:selectOneMenu id="mainGroup" value="#{df.group.mainGroup.id}"
valueChangeListener="#{dfAdmin.mainGroupSelectOneListener}" style="width:150px">
<p:ajax event="valueChange" immediate="true" process="@this" render=":form_df_datatable:group"/>
<f:selectItem itemLabel="Register wählen" itemValue=""
noSelectionOption="true" />
<f:selectItems
value="#{mainGroupService.getMappedGroups().entrySet()}" var="entry"
itemValue="#{entry.key}" itemLabel="#{entry.value}" />
</p:selectOneMenu>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Gruppe">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{dfAdmin.getGroupLabel(df.group.id)}" />
</f:facet>
<f:facet name="input">
<p:selectOneMenu id="group" value="#{df.group.id}"
style="width:150px">
<f:selectItem itemLabel="Gruppe wählen" itemValue=""
noSelectionOption="true" />
<f:selectItems
value="#{groupService.getMappedGroupsForMainGroup(df.group.mainGroup.id).entrySet()}" var="entry"
itemValue="#{entry.key}" itemLabel="#{entry.value}" />
</p:selectOneMenu>
</f:facet>
</p:cellEditor>
</p:column>
请注意,您必须将其设置在上一个视图控制器上,而不是最顶层的视图控制器上。你还必须设置空格字符而不是空字符串!!!
您也可以直接在故事板上执行此操作