我目前有视图控制器 A 和视图控制器 B。
按下按钮时,视图控制器 A 将 vc B 推到它的 navigationController 上:
navigationController?.pushViewController(viewControllerB, animated: true)
VC A 有一个导航栏,上面有一个标题“View Controller A Title”
我希望VC B 有一个左按钮,它是一个后退按钮和一个标题,“视图控制器 B 标题”
目前,当我将 VC B 推到导航控制器上时,VC A 的标题与它一起出现在左后箭头上,所以它看起来像
< View Controller A Title View Controller B Title
我如何摆脱 VC A 标题?
我试过设置左栏按钮项,后栏按钮项,但都没有成功。
我发现删除该标题的唯一方法是
navigationController?.navigationBar.items?.forEach({ $0.title = "" }) 在 VC B 的 viewDidLoad 内部,但是当我单击后退箭头时,VC A 中当然缺少标题
我为上面列出的这个解决方案找到的唯一解决方案是在 VC A 的 viewDidAppear 中设置 navigationItem.title,但是从标题实际显示大约有 1/2 秒的延迟,这并不理想。
有没有更好的方法让这个标题不与导航左栏项目一起出现?
先感谢您!
uinavigationcontroller uibarbuttonitem pushviewcontroller navigationbar swift
当使用设计库'com.android.support:design:28.0.0'BottomNavigationView 错误地显示带有长文本的项目标题时:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".mvp.ui.activities.MainActivity">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="0dp"
android:layout_marginBottom="56dp"
android:layout_above="@+id/navigation"
android:id="@+id/fragmentContent" />
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
app:labelVisibilityMode="labeled"
app:itemHorizontalTranslationEnabled="false"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/navigation" />
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
它看起来很奇怪,因为使用设计库时完全相同的代码com.android.support:design:27.1.1会生成很好的结果:
这怎么可能?对于我尝试使用的新版本的库labelVisibilityMode,但这没有帮助。
app:showAsAction="always"也不行。有任何想法吗?
android navigationbar bottomnavigationview android-bottomnav
我已经检查过像我这样的类似问题,但没有一个有帮助。我还使用相同的 AppTheme 检查了我以前的项目,它们是相同的,但我注意到每次我创建一个新的 android 项目时,即使在几次“重建项目”之后,应用程序栏也不会显示。
这就是我的 styles.xml 显示的内容
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
这是我的 AndroidManifest.xml 显示的内容
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mycontact">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
我的 MainActivity.java (尚未放置代码)
package com.example.mycontact;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) …Run Code Online (Sandbox Code Playgroud) 我有两个不同的页面。其中一个是表单,另一个是元素列表。如果您向左滑动其中一个元素可以进行编辑。我需要将元素数据(从列表中)发送到第一页(表单)
当应用程序启动时,数据为空,如果它来自元素列表则不为空。
导航条码为:
import 'package:flutter/material.dart';
import 'package:datameter/screens/configuration/form/partials/home_page.dart';
import 'package:datameter/screens/configuration/list/datameters.dart';
import 'package:datameter/locations/locations.dart';
class Navigation extends StatefulWidget {
final item;
Navigation(
{Key key,
this.item})
: super(key: key);
@override
State<StatefulWidget> createState() {
return _NavigationState();
}
}
class _NavigationState extends State<Navigation> {
int currentIndex = 0;
List<Widget> children = [
HomePageScreen(datameter: widget.item), //ERRROR HERE
DatametersPageScreen(),
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: children[currentIndex],
bottomNavigationBar: new Theme(
data: Theme.of(context).copyWith(
primaryColor: Colors.blue[700],
textTheme: Theme.of(context)
.textTheme
.copyWith(caption: new TextStyle(color: Colors.black)),
),
child: BottomNavigationBar(
onTap: onTabTapped, …Run Code Online (Sandbox Code Playgroud) 我只想隐藏一个视图控制器的导航栏,该视图控制器是 UINavigationController 的根视图控制器。
目前我正在使用下面的代码来隐藏特定视图控制器的导航栏。
override func viewWillAppear(_ animated: Bool) {
self.navigationController?.isNavigationBarHidden = true
super.viewWillAppear(animated)
}
Run Code Online (Sandbox Code Playgroud)
override func viewWillDisappear(_ animated: Bool) {
self.navigationController?.isNavigationBarHidden = false
super.viewWillDisappear(animated)
}
Run Code Online (Sandbox Code Playgroud)
当我尝试使用此代码时,应用程序在 iOS 13 设备中崩溃,因为线程冲突:预期主线程。
请检查我使用上面的代码隐藏导航栏时遇到的问题,
请告诉我是否有其他方法可以仅隐藏一个视图控制器的导航栏。
在主页中,我根据导航栏选项将小部件调用到我的主体 main.dart,在主页中它有一个图像列表,如果我单击其中一个图像,它会向我显示详细信息。问题是详细信息页面中的导航栏仍然显示。如何隐藏导航栏?
Main.dart
class MyApp extends StatefulWidget {
@override
_NavState createState() => _NavState();
}
class _NavState extends State {
int _selectedIndex = 0;
final _widgetOptions = [
Breakfast(),
Desert(),
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: _widgetOptions.elementAt(_selectedIndex),
bottomNavigationBar: Container(
color: Colors.grey[100],
child: DefaultTabController(
length: 2,
child: TabBar(
indicatorColor: Colors.grey,
labelColor: Colors.blueAccent,
unselectedLabelColor: Colors.grey,
onTap: _onItemTapped,
tabs: [
Tab(
text: 'Breakfast',
),
Tab(
text: 'Dessert',
),
],
),
),
),
);
}
void _onItemTapped(int index) {
setState(() {
_selectedIndex …Run Code Online (Sandbox Code Playgroud) 我想使用这个导航条码,它工作正常,但问题是我不知道如何使项目可点击到每个项目显示我想要的 dart 文件?例如: add: show add.dart、list :show list.dart 和 ...
这是代码:
import 'package:flutter/material.dart';
import 'package:curved_navigation_bar/curved_navigation_bar.dart';
void main() => runApp(MaterialApp(home: BottomNavBar()));
class BottomNavBar extends StatefulWidget {
@override
_BottomNavBarState createState() => _BottomNavBarState();
}
class _BottomNavBarState extends State<BottomNavBar> {
int _page = 0;
GlobalKey _bottomNavigationKey = GlobalKey();
@override
Widget build(BuildContext context) {
return Scaffold(
bottomNavigationBar: CurvedNavigationBar(
key: _bottomNavigationKey,
index: 0,
height: 50.0,
items: <Widget>[
Icon(Icons.add, size: 30),
Icon(Icons.list, size: 30),
Icon(Icons.compare_arrows, size: 30),
Icon(Icons.call_split, size: 30),
Icon(Icons.perm_identity, size: 30),
],
color: Colors.white,
buttonBackgroundColor: …Run Code Online (Sandbox Code Playgroud) 我想用 UIImage 和 UILabel 放置导航栏标题。
\nlet image = UIImage(systemName: "flame")\nimageView.tintColor = R.color.fire()\nself.navigationItem.titleView = imageView\nself.navigationItem.title = "\xed\x91\x9c\xec\x8b\x9c\xed\x95\x9c \xec\xa0\x9c\xed\x92\x88"\nself.navigationController?.navigationBar.titleTextAttributes = [.foregroundColor: R.color.myPageMenu]\nRun Code Online (Sandbox Code Playgroud)\n这是我的代码,但此代码仅显示UIImage(systemName: "flame").
对于具有"独特"设计的iphone项目(我根本不满意),我需要绘制一个自定义视图,该视图与UINavigationController中控制器的导航栏部分重叠.目标是iphone/ios 6,具有固定的设备方向(纵向).
我的电流的解决方案是通过禁用编程导航栏self.navigationController.navigationBar.hidden = YES;在viewDidLoad我的控制器,并画出一个"假"的导航栏,油漆过这一点.这导致状态栏颜色保持黑色的问题(因为没有可见的真实导航栏).这里讨论Ios 6状态栏颜色:iOS 6中的状态栏颜色?
我已经尝试使用[self.view insertSubview:OVERLAPVIEW aboveSubView:self.navigationController.navigationBar]但它没有用,并且在导航栏下方绘制了OVERLAPVIEW.
是否有另一种方法可以将导航栏与另一个视图重叠(z-wise)?或者有没有办法在没有显示导航栏时更改状态栏颜色(不幸的是,除此之外,具有重叠的视图是应用程序的主视图和用户可见的第一个屏幕)
完全披露:我是ios noob和堆栈溢出潜伏者 - 这是我关于堆栈溢出的第一个问题,请帮助我澄清我的问题并在必要时提高我的堆栈溢出技能.
我只是想使用导航栏UIViewController.
在iOS7中,如果我们使用导航控制器,导航栏高度为64px.
但是当我使用导航栏时UIViewController,我无法改变导航栏的高度.
高度固定44px.
如何使用"界面"构建器更改导航栏的高度,而不是编程?

Apple在xcode storyboard中不支持此功能?